make make_patchnum.sh (more) portable
[p5sagit/p5-mst-13.2.git] / scope.c
diff --git a/scope.c b/scope.c
index 78d796b..cad14de 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -648,6 +648,8 @@ Perl_leave_scope(pTHX_ I32 base)
     void* ptr;
     register char* str;
     I32 i;
+    /* Localise the effects of the TAINT_NOT inside the loop.  */
+    const bool was = PL_tainted;
 
     if (base < -1)
        Perl_croak(aTHX_ "panic: corrupt saved stack index");
@@ -902,19 +904,18 @@ Perl_leave_scope(pTHX_ I32 base)
            sv = MUTABLE_SV(SSPOPPTR);
            hv = MUTABLE_HV(SSPOPPTR);
            ptr = hv_fetch_ent(hv, sv, 1, 0);
+           SvREFCNT_dec(sv);
            if (ptr) {
                const SV * const oval = HeVAL((HE*)ptr);
                if (oval && oval != &PL_sv_undef) {
                    ptr = &HeVAL((HE*)ptr);
                    if (SvTIED_mg((const SV *)hv, PERL_MAGIC_tied))
                        SvREFCNT_inc_void(*(SV**)ptr);
-                   SvREFCNT_dec(sv);
                    av = MUTABLE_AV(hv); /* what to refcnt_dec */
                    goto restore_sv;
                }
            }
            SvREFCNT_dec(hv);
-           SvREFCNT_dec(sv);
            SvREFCNT_dec(value);
            break;
        case SAVEt_OP:
@@ -1066,6 +1067,8 @@ Perl_leave_scope(pTHX_ I32 base)
            Perl_croak(aTHX_ "panic: leave_scope inconsistency");
        }
     }
+
+    PL_tainted = was;
 }
 
 void