summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2015-06-22 21:46:09 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2015-06-26 23:09:40 -0400
commitc818886eed9600c1067557ed417280eeecff009b (patch)
treec291b32524a622d357f1fb8ca562817b708f1416 /hv.c
parent61f2771d8144caf40d927b8e1f74264974e31c7a (diff)
downloadperl-c818886eed9600c1067557ed417280eeecff009b.tar.gz
mg_find can return NULL.
CID 104831: Dereference null return value (NULL_RETURNS) 43. dereference: Dereferencing a pointer that might be null Perl_mg_find(sv, 112) when calling Perl_magic_existspack. (The dereference is assumed on the basis of the 'nonnull' parameter attribute.) 499 magic_existspack(svret, mg_find(sv, PERL_MAGIC_tiedelem));
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/hv.c b/hv.c
index e5bf629b4a..f81de13ea1 100644
--- a/hv.c
+++ b/hv.c
@@ -496,7 +496,11 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
}
if (flags & HVhek_FREEKEY)
Safefree(key);
- magic_existspack(svret, mg_find(sv, PERL_MAGIC_tiedelem));
+ {
+ MAGIC * const mg = mg_find(sv, PERL_MAGIC_tiedelem);
+ if (mg)
+ magic_existspack(svret, mg);
+ }
/* This cast somewhat evil, but I'm merely using NULL/
not NULL to return the boolean exists.
And I know hv is not NULL. */