From: Vincent Pit Date: Tue, 10 Mar 2015 19:33:52 +0000 (-0300) Subject: Simplify vmg_call_sv() so that ERRSV is no longer used as a lvalue X-Git-Tag: rt101410~2 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=aae88f4cf6f2f32553f8cc29cb8f0792cb5cd910 Simplify vmg_call_sv() so that ERRSV is no longer used as a lvalue It's less hackish and more resilient to core changes. --- diff --git a/Magic.xs b/Magic.xs index 9a07ac5..61bc9e0 100644 --- a/Magic.xs +++ b/Magic.xs @@ -285,8 +285,8 @@ STATIC I32 vmg_call_sv(pTHX_ SV *sv, I32 flags, int (*cleanup)(pTHX_ void *), vo SV *old_err = NULL; if (SvTRUE(ERRSV)) { - old_err = ERRSV; - ERRSV = newSV(0); + old_err = newSVsv(ERRSV); + sv_setsv(ERRSV, &PL_sv_undef); } cxix = (cxstack_ix < cxstack_max) ? (cxstack_ix + 1) : Perl_cxinc(aTHX); @@ -299,11 +299,8 @@ STATIC I32 vmg_call_sv(pTHX_ SV *sv, I32 flags, int (*cleanup)(pTHX_ void *), vo cxstack[cxix] = saved_cx; if (SvTRUE(ERRSV)) { - if (old_err) { - sv_setsv(old_err, ERRSV); - SvREFCNT_dec(ERRSV); - ERRSV = old_err; - } + SvREFCNT_dec(old_err); + if (IN_PERL_COMPILETIME) { if (!PL_in_eval) { if (PL_errors) @@ -326,8 +323,8 @@ STATIC I32 vmg_call_sv(pTHX_ SV *sv, I32 flags, int (*cleanup)(pTHX_ void *), vo } } else { if (old_err) { - SvREFCNT_dec(ERRSV); - ERRSV = old_err; + sv_setsv(ERRSV, old_err); + SvREFCNT_dec(old_err); } }