]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ds: write: do not assume final wbuf entry is tmpio
authorEric Wong <e@80x24.org>
Fri, 24 Feb 2023 16:59:10 +0000 (16:59 +0000)
committerEric Wong <e@80x24.org>
Sun, 26 Feb 2023 16:44:03 +0000 (16:44 +0000)
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

index 0a763d0ef643ad0d5c5deb8e027b9df67d4438ae..a08e01f540bb34e07689030a0880035ce2f193d2 100644 (file)
@@ -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;