From: Nicholas Clark Date: Sun, 16 Apr 2006 09:36:18 +0000 (+0000) Subject: Coverity notes that we might be dereferencing fgv before a check that X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4a7049d1e66956838433895a259b4fb84d25493;p=p5sagit%2Fp5-mst-13.2.git Coverity notes that we might be dereferencing fgv before a check that it's not NULL. In fact, the code ordering meant that one "if (fgv)" would always be true. So fix this. p4raw-id: //depot/perl@27837 --- diff --git a/pp_sys.c b/pp_sys.c index 260f7b2..5c9bfea 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1277,16 +1277,17 @@ PP(pp_enterwrite) else fgv = gv; + if (!fgv) { + DIE(aTHX_ "Not a format reference"); + } cv = GvFORM(fgv); if (!cv) { - if (fgv) { - SV * const tmpsv = sv_newmortal(); - const char *name; - gv_efullname4(tmpsv, fgv, NULL, FALSE); - name = SvPV_nolen_const(tmpsv); - if (name && *name) - DIE(aTHX_ "Undefined format \"%s\" called", name); - } + SV * const tmpsv = sv_newmortal(); + const char *name; + gv_efullname4(tmpsv, fgv, NULL, FALSE); + name = SvPV_nolen_const(tmpsv); + if (name && *name) + DIE(aTHX_ "Undefined format \"%s\" called", name); DIE(aTHX_ "Not a format reference"); } if (CvCLONE(cv))