--- sv.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sv.c b/sv.c index 95ad106..811d8ce 100644 --- a/sv.c +++ b/sv.c @@ -5209,12 +5209,14 @@ Perl_sv_unmagic(pTHX_ SV *const sv, const int type) else mgp = &mg->mg_moremagic; } - if (!SvMAGIC(sv)) { + if (SvMAGIC(sv)) { + if (SvMAGICAL(sv)) /* if we're under save_magic, wait for restore_magic; */ + mg_magical(sv); /* else fix the flags now */ + } + else { SvMAGICAL_off(sv); SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; - SvMAGIC_set(sv, NULL); } - return 0; } -- 1.6.5.4