From: Eric Wong Date: Fri, 24 Feb 2023 16:59:10 +0000 (+0000) Subject: ds: write: do not assume final wbuf entry is tmpio X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f334acf7b3a4fc8aac52d0281e9c2af97d8addd;p=thirdparty%2Fpublic-inbox.git ds: write: do not assume final wbuf entry is tmpio 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. --- diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 0a763d0ef..a08e01f54 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;