]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: avoid unnecessary on-stack delete
authorEric Wong <e@80x24.org>
Sun, 7 Feb 2021 08:52:00 +0000 (08:52 +0000)
committerEric Wong <e@80x24.org>
Sun, 7 Feb 2021 22:57:29 +0000 (22:57 +0000)
None of the Content-Type attributes are long-lived
(and unlikely to be memory intensive).  While these
callsites won't trigger $DB::args segfaults via
confess or longmess, it'll make future code audits
easier.

cf. commit 0795b0906cc81f40
    ("ds: guard against stack-not-refcounted quirk of Perl 5")

lib/PublicInbox/IMAP.pm

index 226e98a2e2a144930d221fe798d663ab3feb78ad..af8ce72be48a61df36bec17183fa061a0f2bffae 100644 (file)
@@ -499,7 +499,7 @@ sub body_disposition ($) {
        my $cd = $eml->header_raw('Content-Disposition') or return 'NIL';
        $cd = parse_content_disposition($cd);
        my $buf = '('._esc($cd->{type});
-       $buf .= ' ' . _esc_hash(delete $cd->{attributes});
+       $buf .= ' ' . _esc_hash($cd->{attributes});
        $buf .= ')';
 }
 
@@ -511,7 +511,7 @@ sub body_leaf ($$;$) {
        my $ct = $eml->ct;
        $buf .= '('._esc($ct->{type}).' ';
        $buf .= _esc($ct->{subtype});
-       $buf .= ' ' . _esc_hash(delete $ct->{attributes});
+       $buf .= ' ' . _esc_hash($ct->{attributes});
        $buf .= ' ' . _esc($eml->header_raw('Content-ID'));
        $buf .= ' ' . _esc($eml->header_raw('Content-Description'));
        my $cte = $eml->header_raw('Content-Transfer-Encoding') // '7bit';
@@ -540,7 +540,7 @@ sub body_parent ($$$) {
                $buf .= @$hold ? join('', @$hold) : 'NIL';
                $buf .= ' '._esc($ct->{subtype});
                if ($structure) {
-                       $buf .= ' '._esc_hash(delete $ct->{attributes});
+                       $buf .= ' '._esc_hash($ct->{attributes});
                        $buf .= ' '.body_disposition($eml);
                        $buf .= ' '._esc($eml->header_raw('Content-Language'));
                        $buf .= ' '._esc($eml->header_raw('Content-Location'));