diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2015-06-22 21:46:09 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2015-06-26 23:09:40 -0400 |
commit | c818886eed9600c1067557ed417280eeecff009b (patch) | |
tree | c291b32524a622d357f1fb8ca562817b708f1416 /hv.c | |
parent | 61f2771d8144caf40d927b8e1f74264974e31c7a (diff) | |
download | perl-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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. */ |