develooper Front page | perl.perl5.porters | Postings from April 2006

[PATCH] Handle null io in leavewrite (not possible?) (Coverity)

Thread Next
From:
bah
Date:
April 15, 2006 16:21
Subject:
[PATCH] Handle null io in leavewrite (not possible?) (Coverity)
Message ID:
1661.38.96.138.153.1145124821.squirrel@mail.longitude.com
Is this situation even possible?

Ben

--- pp_sys.c.orig	2006-04-15 12:03:16.000000000 -0400
+++ pp_sys.c	2006-04-15 12:02:54.000000000 -0400
@@ -1301,16 +1301,18 @@
     dVAR; dSP;
     GV * const gv = cxstack[cxstack_ix].blk_sub.gv;
     register IO * const io = GvIOp(gv);
-    PerlIO * const ofp = IoOFP(io);
+    PerlIO * const 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)
     {

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About