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=-4.0 required=3.0 tests=ALL_TRUSTED,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 2F8E21F4B4 for ; Tue, 15 Sep 2020 06:11:18 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] imap: quiet uninitialized variable warning on FETCH Date: Tue, 15 Sep 2020 06:11:18 +0000 Message-Id: <20200915061118.27220-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This was triggered by blindly trying to FETCH an MSN (not "UID FETCH") on an empty dummy inbox. It's harmless, and probably triggered by a wayward client or misbehaving bot. --- lib/PublicInbox/IMAP.pm | 2 +- t/imapd.t | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 2d0d005e..47c08aea 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -300,7 +300,7 @@ sub msn2uid ($) { # converts a set of message sequence numbers in requests to UIDs: sub msn_to_uid_range ($$) { my $msn2uid = $_[0]; - $_[1] =~ s!([0-9]+)!$msn2uid->[$1 - 1] // ($msn2uid->[-1] + 1)!sge; + $_[1] =~ s!([0-9]+)!$msn2uid->[$1 - 1] // ($msn2uid->[-1] // 0 + 1)!sge; } # called by PublicInbox::InboxIdle diff --git a/t/imapd.t b/t/imapd.t index cb95fa5d..c1c52839 100644 --- a/t/imapd.t +++ b/t/imapd.t @@ -371,6 +371,10 @@ EOF @hits = $mic->search('SENTSINCE' => '18-Apr-2020'); is_deeply(\@hits, [], 'search on dummy with condition works'); ok(!$mic->search('SENTSINCE' => '18-Abr-2020'), 'bad month fails'); + $mic->Uid(0); + my $ret = $mic->fetch_hash(2, 'RFC822'); + is_deeply($ret, {}, + 'MSN FETCH on empty dummy will not trigger warnings, later'); }); # each_inbox # message sequence numbers :<