Re: Making IO::Socket pass test on Win32
[p5sagit/p5-mst-13.2.git] / scope.c
diff --git a/scope.c b/scope.c
index 2c61424..0070f63 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -62,7 +62,7 @@ Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
     Newx(si->si_cxstack, cxitems, PERL_CONTEXT);
     /* Without any kind of initialising PUSHSUBST()
      * in pp_subst() will read uninitialised heap. */
-    Poison(si->si_cxstack, cxitems, PERL_CONTEXT);
+    PoisonNew(si->si_cxstack, cxitems, PERL_CONTEXT);
     return si;
 }
 
@@ -75,7 +75,7 @@ Perl_cxinc(pTHX)
     Renew(cxstack, cxstack_max + 1, PERL_CONTEXT);     /* XXX should fix CXINC macro */
     /* Without any kind of initialising deep enough recursion
      * will end up reading uninitialised PERL_CONTEXTs. */
-    Poison(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
+    PoisonNew(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
     return cxstack_ix + 1;
 }
 
@@ -166,6 +166,7 @@ S_save_scalar_at(pTHX_ SV **sptr)
     register SV * const sv = *sptr = newSV(0);
 
 #ifdef PERL_MAD
+    /* FIXME for MAD - this is causing ext/Safe/t/safeops.t to abort.  */
     if (PL_formfeed && sv == PL_formfeed)
        abort();
 #endif
@@ -825,7 +826,7 @@ Perl_leave_scope(pTHX_ I32 base)
            ptr = SSPOPPTR;
            hv = (HV*)ptr;
            ptr = SSPOPPTR;
-           (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
+           (void)hv_delete(hv, (char*)ptr, (I32)SSPOPINT, G_DISCARD);
            SvREFCNT_dec(hv);
            Safefree(ptr);
            break;
@@ -889,11 +890,33 @@ Perl_leave_scope(pTHX_ I32 base)
                GvHV(PL_hintgv) = NULL;
            }
            *(I32*)&PL_hints = (I32)SSPOPINT;
+           Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints);
+           PL_compiling.cop_hints = (struct refcounted_he *) SSPOPPTR;
            if (PL_hints & HINT_LOCALIZE_HH) {
                SvREFCNT_dec((SV*)GvHV(PL_hintgv));
                GvHV(PL_hintgv) = (HV*)SSPOPPTR;
+               assert(GvHV(PL_hintgv));
+           } else if (!GvHV(PL_hintgv)) {
+               /* Need to add a new one manually, else gv_fetchpv() can
+                  add one in this code:
+                  
+                  if (SvTYPE(gv) == SVt_PVGV) {
+                      if (add) {
+                      GvMULTI_on(gv);
+                      gv_init_sv(gv, sv_type);
+                      if (*name=='!' && sv_type == SVt_PVHV && len==1)
+                          require_errno(gv);
+                      }
+                      return gv;
+                  }
+
+                  and it won't have the magic set.  */
+
+               HV *const hv = newHV();
+               hv_magic(hv, NULL, PERL_MAGIC_hints);
+               GvHV(PL_hintgv) = hv;
            }
-                   
+           assert(GvHV(PL_hintgv));
            break;
        case SAVEt_COMPPAD:
            PL_comppad = (PAD*)SSPOPPTR;
@@ -958,6 +981,11 @@ Perl_leave_scope(pTHX_ I32 base)
            ptr = SSPOPPTR;
            (*SSPOPDPTR)(ptr);
            break;
+       case SAVEt_COP_ARYBASE:
+           ptr = SSPOPPTR;
+           i = SSPOPINT;
+           CopARYBASE_set((COP *)ptr, i);
+           break;
        default:
            Perl_croak(aTHX_ "panic: leave_scope inconsistency");
        }