]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Skip wizard destructor during global destruction
[perl/modules/Variable-Magic.git] / Magic.xs
index 89df570ec4d896ae54599ad0408221dccbcb1a64..1ac63cbf205ae3ac2ed6090033cb57530e5459c5 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -623,6 +623,9 @@ STATIC int vmg_wizard_free(pTHX_ SV *wiz, MAGIC *mg) {
  MGWIZ *w;
  dMY_CXT;
 
+ if (PL_dirty) /* during global destruction, the context is already freed */
+  return 0;
+
  w = SV2MGWIZ(wiz);
 
  if (hv_delete(MY_CXT.wizz, buf, sprintf(buf, "%u", w->sig), 0)) {
@@ -834,6 +837,7 @@ CODE:
  sv = MGWIZ2SV(w);
  mg = sv_magicext(sv, NULL, PERL_MAGIC_ext, &vmg_wizard_vtbl, NULL, -1);
  mg->mg_private = SIG_WIZ;
+ SvREADONLY_on(sv);
 
  hv_store(MY_CXT.wizz, buf, sprintf(buf, "%u", sig), sv, 0);
  ++MY_CXT.count;