A new fatal error :
[p5sagit/p5-mst-13.2.git] / pp_hot.c
index 3bc448d..b740007 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1,6 +1,7 @@
 /*    pp_hot.c
  *
- *    Copyright (c) 1991-2003, Larry Wall
+ *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ *    2000, 2001, 2002, 2003, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -1858,6 +1859,12 @@ PP(pp_iter)
     else {
        sv = AvARRAY(av)[++cx->blk_loop.iterix];
     }
+    if (sv && SvREFCNT(sv) == 0) {
+       *itersvp = Nullsv;
+       Perl_croak(aTHX_
+           "Use of freed value in iteration (perhaps you modified the iterated array within the loop?)");
+    }
+
     if (sv)
        SvTEMP_off(sv);
     else
@@ -2928,15 +2935,16 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
        packname = Nullch;
 
         if(SvOK(sv) && (packname = SvPV(sv, packlen))) {
-          HE* he = hv_fetch_ent(PL_stashcache, sv, 0, 0);
+          HE* he;
+         he = hv_fetch_ent(PL_stashcache, sv, 0, 0);
           if (he) { 
-            stash = HeVAL(he);
+            stash = (HV*)SvIV(HeVAL(he));
             goto fetch;
           }
         }
 
        if (!SvOK(sv) ||
-           !(packname = SvPV(sv, packlen)) ||
+           !(packname) ||
            !(iogv = gv_fetchpv(packname, FALSE, SVt_PVIO)) ||
            !(ob=(SV*)GvIO(iogv)))
        {
@@ -2956,10 +2964,9 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
            if (!stash)
                packsv = sv;
             else {
-              SvREFCNT_inc((SV*)stash);
-              if(!hv_store(PL_stashcache, packname, packlen, stash, 0))
-                SvREFCNT_dec((SV*)stash);
-            }
+               SV* ref = newSViv((IV)stash);
+               hv_store(PL_stashcache, packname, packlen, ref, 0);
+           }
            goto fetch;
        }
        /* it _is_ a filehandle name -- replace with a reference */