This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make POPGIVEN re-entrant safe
authorDavid Mitchell <davem@iabyn.com>
Mon, 19 Oct 2015 16:14:58 +0000 (17:14 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:18:31 +0000 (09:18 +0000)
cop.h

diff --git a/cop.h b/cop.h
index f6280a9..d95c799 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -873,8 +873,12 @@ struct block_givwhen {
        NOOP;
 
 #define POPGIVEN(cx)                                                    \
-        SvREFCNT_dec(GvSV(PL_defgv));                                   \
-        GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;
+    STMT_START {                                                       \
+        SV *sv = GvSV(PL_defgv);                                        \
+        GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;                    \
+        cx->blk_givwhen.defsv_save = NULL;                              \
+        SvREFCNT_dec(sv);                                               \
+    } STMT_END
 
 
 /* basic block, i.e. pp_enter/leave */