]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Remove a now obsolete workaround for context stack smashing
[perl/modules/Variable-Magic.git] / Magic.xs
index 69ad981a726d862427de4e88d96de34b3a689432..483431e9eaa6925e4561837fc1f26ab66d51e42d 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -331,8 +331,7 @@ static MAGIC *vmg_sv_magicext(pTHX_ SV *sv, SV *obj, const MGVTBL *vtbl, const v
 
 static I32 vmg_call_sv(pTHX_ SV *sv, I32 flags, int (*cleanup)(pTHX_ void *), void *ud) {
 #define vmg_call_sv(S, F, C, U) vmg_call_sv(aTHX_ (S), (F), (C), (U))
- I32 ret, cxix;
- PERL_CONTEXT saved_cx;
+ I32 ret;
  SV *old_err = NULL;
 
  if (SvTRUE(ERRSV)) {
@@ -340,15 +339,8 @@ static I32 vmg_call_sv(pTHX_ SV *sv, I32 flags, int (*cleanup)(pTHX_ void *), vo
   sv_setsv(ERRSV, &PL_sv_undef);
  }
 
- cxix     = (cxstack_ix < cxstack_max) ? (cxstack_ix + 1) : Perl_cxinc(aTHX);
- /* The last popped context will be reused by call_sv(), but our callers may
-  * still need its previous value. Back it up so that it isn't clobbered. */
- saved_cx = cxstack[cxix];
-
  ret = call_sv(sv, flags | G_EVAL);
 
- cxstack[cxix] = saved_cx;
-
  if (SvTRUE(ERRSV)) {
   SvREFCNT_dec(old_err);
 
@@ -857,6 +849,8 @@ static SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, SV **args, I32 items) {
  ENTER;
  SAVETMPS;
 
+ PUSHSTACKi(PERLSI_MAGIC);
+
  PUSHMARK(SP);
  EXTEND(SP, items + 1);
  PUSHs(sv_2mortal(newRV_inc(sv)));
@@ -875,6 +869,8 @@ static SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, SV **args, I32 items) {
 #endif
  PUTBACK;
 
+ POPSTACK;
+
  FREETMPS;
  LEAVE;
 
@@ -1260,6 +1256,8 @@ static int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) {
  ENTER;
  SAVETMPS;
 
+ PUSHSTACKi(PERLSI_MAGIC);
+
  PUSHMARK(SP);
  EXTEND(SP, args + 1);
  PUSHs(sv_2mortal(newRV_inc(sv)));
@@ -1294,6 +1292,8 @@ static int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) {
   svr = NULL;
  PUTBACK;
 
+ POPSTACK;
+
  FREETMPS;
  LEAVE;
 
@@ -1370,6 +1370,8 @@ static U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) {
  ENTER;
  SAVETMPS;
 
+ PUSHSTACKi(PERLSI_MAGIC);
+
  PUSHMARK(SP);
  EXTEND(SP, 3);
  PUSHs(sv_2mortal(newRV_inc(sv)));
@@ -1397,6 +1399,8 @@ static U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) {
   --ret;
  PUTBACK;
 
+ POPSTACK;
+
  FREETMPS;
  LEAVE;
 
@@ -1571,6 +1575,8 @@ static int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
  ENTER;
  SAVETMPS;
 
+ PUSHSTACKi(PERLSI_MAGIC);
+
  PUSHMARK(SP);
  EXTEND(SP, 2);
  PUSHs(sv_2mortal(newRV_inc(sv)));
@@ -1598,6 +1604,8 @@ static int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
   ret = (int) SvIV(svr);
  PUTBACK;
 
+ POPSTACK;
+
  FREETMPS;
  LEAVE;