summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorNicolas R <atoomic@cpan.org>2020-08-14 16:16:22 -0500
committerℕicolas ℝ <nicolas@atoomic.org>2020-08-21 08:54:54 -0600
commit042abef72d40ab7ff39127e2afae6e34dfc66404 (patch)
tree8dd0b970a29e16d5be7283db321ab8f068898ca5 /pp_ctl.c
parente04d927f2ca4d75153dd8737e2022c37fe5fa2d0 (diff)
downloadperl-042abef72d40ab7ff39127e2afae6e34dfc66404.tar.gz
die_unwind(): global destruction
Fix #18063 During global destruction make sure we preserve the string by using mortalcopy. This is an update on 8c86f0238ecb5f32c2e7fba36e3edfdb54069068 change which avoided sv_mortalcopy in favor of sv_2mortal.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index b8cd869ee0..cc244d7ba7 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1716,7 +1716,11 @@ Perl_die_unwind(pTHX_ SV *msv)
* when unlocalising a tied var). So we do a dance with
* mortalising and SAVEFREEing.
*/
- sv_2mortal(SvREFCNT_inc_simple_NN(exceptsv));
+ if (PL_phase == PERL_PHASE_DESTRUCT) {
+ exceptsv = sv_mortalcopy(exceptsv);
+ } else {
+ exceptsv = sv_2mortal(SvREFCNT_inc_simple_NN(exceptsv));
+ }
/*
* Historically, perl used to set ERRSV ($@) early in the die