From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A7A201F62B for ; Fri, 24 Feb 2023 16:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1677257950; bh=6oh9UbAJ/NW84CGxhSmRjK2PpaA9LDBgpRIoU6VZdG4=; h=From:To:Subject:Date:From; b=47IE+M7YKiia9ECKqnXCXzvmKOnhVK+bwyUMb3E1wQeaYh6jfZqGXdqUns80SuKtV mObRGK62ksEklbvywdzoAhMUIR5gAKwmiW+ZzVZ4oNjjHHoAfGg9b0gTq/mSZ9MoIC fu8P895apaJbDmYhEMukHsivQjC0AYuEGRRscgQw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] ds: write: do not assume final wbuf entry is tmpio Date: Fri, 24 Feb 2023 16:59:10 +0000 Message-Id: <20230224165910.601128-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The final entry of {wbuf} may be a CODE ref and not a tmpio ARRAY ref, so we must ensure it's an ARRAY before attempting to use `->[INDEX]' to access it. This fixes: forward ->close error: Not an ARRAY reference at PublicInbox/DS.pm line 544. --- lib/PublicInbox/DS.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 0a763d0e..a08e01f5 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -541,7 +541,8 @@ sub write { push @$wbuf, $bref; } else { my $tmpio = $wbuf->[-1]; - if ($tmpio && !defined($tmpio->[2])) { # append to tmp file buffer + if (ref($tmpio) eq 'ARRAY' && !defined($tmpio->[2])) { + # append to tmp file buffer $tmpio->[0]->print($$bref) or return drop($self, "print: $!"); } else { my $tmpio = tmpio($self, $bref, 0) or return 0;