From: bah@longitude.com Date: Sat, 15 Apr 2006 14:13:41 +0000 (-0400) Subject: Handle null io in leavewrite (not possible?) (Coverity) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b8cacda97c80b98d5f7759a80b1954285666940;p=p5sagit%2Fp5-mst-13.2.git Handle null io in leavewrite (not possible?) (Coverity) 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 --- diff --git a/pp_sys.c b/pp_sys.c index c8a4638..260f7b2 100644 --- 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) {