Handle null io in leavewrite (not possible?) (Coverity)
bah@longitude.com [Sat, 15 Apr 2006 14:13:41 +0000 (10:13 -0400)]
Message-ID: <1661.38.96.138.153.1145124821.squirrel@mail.longitude.com>
Date: Sat, 15 Apr 2006 14:13:41 -0400 (EDT)

p4raw-id: //depot/perl@27829

pp_sys.c

index c8a4638..260f7b2 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1301,16 +1301,18 @@ PP(pp_leavewrite)
     dVAR; dSP;
     GV * const gv = cxstack[cxstack_ix].blk_sub.gv;
     register IO * const io = GvIOp(gv);
-    PerlIO * const ofp = IoOFP(io);
+    PerlIO *ofp;
     PerlIO *fp;
     SV **newsp;
     I32 gimme;
     register PERL_CONTEXT *cx;
 
+    if (!io || !(ofp = IoOFP(io)))
+        goto forget_top;
+
     DEBUG_f(PerlIO_printf(Perl_debug_log, "left=%ld, todo=%ld\n",
          (long)IoLINES_LEFT(io), (long)FmLINES(PL_formtarget)));
-    if (!io || !ofp)
-       goto forget_top;
+
     if (IoLINES_LEFT(io) < FmLINES(PL_formtarget) &&
        PL_formtarget != PL_toptarget)
     {