X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Magic.xs;h=985b37ff1771e3fbc3984062f2963e105b138700;hb=7093e2e5da555110174261aa42ac7bbf78fa238b;hp=41bf22dcd5068d655e6a3ba0d7139b64b39b9d17;hpb=62f99fdfd379e0be431040ba68cd90f0683701d0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/Magic.xs b/Magic.xs index 41bf22d..985b37f 100644 --- a/Magic.xs +++ b/Magic.xs @@ -670,13 +670,13 @@ STATIC int vmg_svt_clear(pTHX_ SV *sv, MAGIC *mg) { } STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) { - SV *wiz = (SV *) mg->mg_ptr; const MGWIZ *w; unsigned int flags; int ret = 0; - /* This may happen in global destruction */ - if (SvTYPE(wiz) == SVTYPEMASK) + /* Don't even bother if we are in global destruction - the wizard is prisoner + * of circular references and we are way beyond user realm */ + if (PL_dirty) return 0; w = SV2MGWIZ(mg->mg_ptr); @@ -1086,8 +1086,11 @@ CODE: STRLEN len; char *sig = HePV(key, len); SV *sv; + const MGWIZ *w; MAGIC *mg; - sv = MGWIZ2SV(vmg_wizard_clone(SV2MGWIZ(HeVAL(key)))); + w = SV2MGWIZ(HeVAL(key)); + w = vmg_wizard_clone(w); + sv = MGWIZ2SV(w); mg = sv_magicext(sv, NULL, PERL_MAGIC_ext, &vmg_wizard_vtbl, NULL, 0); mg->mg_private = SIG_WIZ; SvREADONLY_on(sv);