summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index ca953ad05e..cb549fa841 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4273,8 +4273,15 @@ PP(pp_entergiven)
ENTER_with_name("given");
SAVETMPS;
- SAVECLEARSV(PAD_SVl(PL_op->op_targ));
- sv_setsv_mg(PAD_SV(PL_op->op_targ), POPs);
+ if (PL_op->op_targ) {
+ SAVEPADSVANDMORTALIZE(PL_op->op_targ);
+ SvREFCNT_dec(PAD_SVl(PL_op->op_targ));
+ PAD_SVl(PL_op->op_targ) = SvREFCNT_inc_NN(POPs);
+ }
+ else {
+ SAVE_DEFSV;
+ DEFSV_set(POPs);
+ }
PUSHBLOCK(cx, CXt_GIVEN, SP);
PUSHGIVEN(cx);