This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Followup to 316ebaf (aka perl #121894).
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 17:24:36 +0000 (13:24 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 17:51:47 +0000 (13:51 -0400)
Adding asserts to more spots.

Fix for Coverity perl5 CIDs 28962,28968,28969:
CID ...: Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer p->q

ext/XS-APItest/APItest.xs
pp_sys.c

index 1e750c3..31724f9 100644 (file)
@@ -1457,12 +1457,16 @@ common(params)
            hash = SvUV(*svp);
 
        if (hv_fetchs(params, "hash_pv", 0)) {
+            assert(key);
            PERL_HASH(hash, key, klen);
        }
        if (hv_fetchs(params, "hash_sv", 0)) {
-           STRLEN len;
-           const char *const p = SvPV(keysv, len);
-           PERL_HASH(hash, p, len);
+            assert(keysv);
+            {
+              STRLEN len;
+              const char *const p = SvPV(keysv, len);
+              PERL_HASH(hash, p, len);
+            }
        }
 
        result = (HE *)hv_common(hv, keysv, key, klen, flags, action, val, hash);
index 1ee3ba2..8151607 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3406,6 +3406,7 @@ PP(pp_fttext)
         const char *file;
         int fd; 
 
+        assert(sv);
        sv_setpv(PL_statname, SvPV_nomg_const_nolen(sv));
       really_filename:
         file = SvPVX_const(PL_statname);