about summary refs log tree commit homepage
path: root/lib/PublicInbox/Eml.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-06 12:18:38 +0000
committerEric Wong <e@80x24.org>2021-02-07 03:34:32 +0000
commita2bae6437eeb8147736812eca95e85e5642c97cc (patch)
tree9aba5ac1c9f07f090a8788755f6e30c6ad371270 /lib/PublicInbox/Eml.pm
parent7f43cdaf0e46c1d99bf5834f414dc8f36407e8cc (diff)
downloadpublic-inbox-a2bae6437eeb8147736812eca95e85e5642c97cc.tar.gz
The PublicInbox::Eml (and previously Email::MIME) use of confess
was the primary (or only) culprit behind the lei2mail segfaults
fixed by commit 0795b0906cc81f40.
("ds: guard against stack-not-refcounted quirk of Perl 5").

We never care about a backtrace when dealing with Eml objects
anyways, so it was just a worthless waste of CPU cycles.

We can also drop confess in a few other places.  Since we only
use Perl and Inline::C, users will never be without source
and can replace s/croak/Carp::confess/ on a per-callsite basis
to help report problems.

It's also possible to use PERL5OPT=-MCarp=verbose in the
environment though still potentially risky.

Link: https://public-inbox.org/meta/20210201082833.3293-1-e@80x24.org/
Diffstat (limited to 'lib/PublicInbox/Eml.pm')
-rw-r--r--lib/PublicInbox/Eml.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm
index f7f62e7b..81a6632b 100644
--- a/lib/PublicInbox/Eml.pm
+++ b/lib/PublicInbox/Eml.pm
@@ -332,7 +332,7 @@ sub body_set {
 sub body_str_set {
         my ($self, $body_str) = @_;
         my $charset = ct($self)->{attributes}->{charset} or
-                Carp::confess('body_str was given, but no charset is defined');
+                croak('body_str was given, but no charset is defined');
         body_set($self, \(encode($charset, $body_str, Encode::FB_CROAK)));
 }
 
@@ -454,7 +454,7 @@ sub body_str {
                 if ($STR_TYPE{$ct->{type}} && $STR_SUBTYPE{$ct->{subtype}}) {
                         return body($self);
                 }
-                Carp::confess("can't get body as a string for ",
+                croak("can't get body as a string for ",
                         join("\n\t", header_raw($self, 'Content-Type')));
         }
         decode($charset, body($self), Encode::FB_CROAK);