From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6079C1FC9F for ; Sun, 7 Feb 2021 08:52:03 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 18/19] imap: avoid unnecessary on-stack delete Date: Sun, 7 Feb 2021 08:52:00 +0000 Message-Id: <20210207085201.13871-19-e@80x24.org> In-Reply-To: <20210207085201.13871-1-e@80x24.org> References: <20210207085201.13871-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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/HTTPD/Async.pm | 2 +- --- lib/PublicInbox/IMAP.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 226e98a2..af8ce72b 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -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'));