This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Coverity notes that we might be dereferencing fgv before a check that
authorNicholas Clark <nick@ccl4.org>
Sun, 16 Apr 2006 09:36:18 +0000 (09:36 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 16 Apr 2006 09:36:18 +0000 (09:36 +0000)
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

pp_sys.c

index 260f7b2..5c9bfea 100644 (file)
--- 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))