From: Vincent Pit Date: Mon, 27 Apr 2009 20:37:28 +0000 (+0200) Subject: Store the last popped stack index for after call_sv() X-Git-Tag: v0.35~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0b64e7c063d300a0be9139d0f155cef806fc5192;p=perl%2Fmodules%2FVariable-Magic.git Store the last popped stack index for after call_sv() This also silences a compilation warning for cxinc(). --- diff --git a/Magic.xs b/Magic.xs index c925143..218819f 100644 --- a/Magic.xs +++ b/Magic.xs @@ -814,6 +814,7 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { const MGWIZ *w; #if VMG_HAS_PERL(5, 10, 0) PERL_CONTEXT saved_cx; + I32 cxix; #endif unsigned int had_err, has_err, flags = G_SCALAR | G_EVAL; int ret = 0; @@ -856,15 +857,17 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { /* This context should not be used anymore, but since we croak in places the * core doesn't even dare to, some pointers to it may remain in the upper call * stack. Make sure call_sv() doesn't clobber it. */ - if (cxstack_ix >= cxstack_max) - Perl_cxinc(aTHX); - saved_cx = cxstack[cxstack_ix + 1]; + if (cxstack_ix < cxstack_max) + cxix = cxstack_ix + 1; + else + cxix = Perl_cxinc(aTHX); + saved_cx = cxstack[cxix]; #endif call_sv(w->cb_free, flags); #if VMG_HAS_PERL(5, 10, 0) - cxstack[cxstack_ix + 1] = saved_cx; + cxstack[cxix] = saved_cx; #endif has_err = SvTRUE(ERRSV);