Do not dereference hv before ensuring it's not NULL
authorRafael Garcia-Suarez <rgs@consttype.org>
Wed, 19 Feb 2014 14:41:51 +0000 (15:41 +0100)
committerRafael Garcia-Suarez <rgs@consttype.org>
Wed, 19 Feb 2014 14:42:18 +0000 (15:42 +0100)
This should fix RT #116441 and possibly other bugs.

hv.c

diff --git a/hv.c b/hv.c
index 1d322fe..a9322aa 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1753,10 +1753,11 @@ Perl_hv_undef_flags(pTHX_ HV *hv, U32 flags)
 {
     dVAR;
     XPVHV* xhv;
-    const bool save = !!SvREFCNT(hv);
+    bool save;
 
     if (!hv)
        return;
+    save = !!SvREFCNT(hv);
     DEBUG_A(Perl_hv_assert(aTHX_ hv));
     xhv = (XPVHV*)SvANY(hv);