This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove trailing blanks
[perl5.git] / pad.c
diff --git a/pad.c b/pad.c
index 2c1c81d..de462c7 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -363,16 +363,20 @@ Perl_cv_undef(pTHX_ CV *cv)
        }
 
        ix = AvFILLp(padlist);
-       while (ix >= 0) {
+       while (ix > 0) {
            SV* const sv = AvARRAY(padlist)[ix--];
            if (sv) {
-               if (sv == (const SV *)PL_comppad_name)
-                   PL_comppad_name = NULL;
-               else if (sv == (const SV *)PL_comppad) {
+               if (sv == (const SV *)PL_comppad) {
                    PL_comppad = NULL;
                    PL_curpad = NULL;
                }
+               SvREFCNT_dec(sv);
            }
+       }
+       {
+           SV *const sv = AvARRAY(padlist)[0];
+           if (sv == (const SV *)PL_comppad_name)
+               PL_comppad_name = NULL;
            SvREFCNT_dec(sv);
        }
        SvREFCNT_dec(MUTABLE_SV(CvPADLIST(cv)));
@@ -662,7 +666,7 @@ S_pad_check_dup(pTHX_ SV *name, const U32 flags, const HV *ourstash)
     }
     /* check the rest of the pad */
     if (is_our) {
-       do {
+       while (off > 0) {
            SV * const sv = svp[off];
            if (sv
                && sv != &PL_sv_undef
@@ -678,7 +682,8 @@ S_pad_check_dup(pTHX_ SV *name, const U32 flags, const HV *ourstash)
                        "\t(Did you mean \"local\" instead of \"our\"?)\n");
                break;
            }
-       } while ( off-- > 0 );
+           --off;
+       }
     }
 }
 
@@ -863,7 +868,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
                 * instances. For now, we just test !CvUNIQUE(cv), but
                 * ideally, we should detect my's declared within loops
                 * etc - this would allow a wider range of 'not stayed
-                * shared' warnings. We also treated alreadly-compiled
+                * shared' warnings. We also treated already-compiled
                 * lexes as not multi as viewed from evals. */
 
                *out_flags = CvANON(cv) ?
@@ -988,7 +993,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn,
 
     {
        /* This relies on sv_setsv_flags() upgrading the destination to the same
-          type as the source, independant of the flags set, and on it being
+          type as the source, independent of the flags set, and on it being
           "good" and only copying flag bits and pointers that it understands.
        */
        SV *new_namesv = newSVsv(*out_name_sv);
@@ -1334,7 +1339,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type)
      * so that for example the eval's CV in C<< sub { eval '$x' } >> gets
      * the right CvOUTSIDE.
      * If running with -d, *any* sub may potentially have an eval
-     * excuted within it.
+     * executed within it.
      */
 
     if (PL_cv_has_eval || PL_perldb) {
@@ -1445,11 +1450,6 @@ Perl_pad_free(pTHX_ PADOFFSET po)
 
     if (PL_curpad[po] && PL_curpad[po] != &PL_sv_undef) {
        SvPADTMP_off(PL_curpad[po]);
-#ifdef USE_ITHREADS
-       /* SV could be a shared hash key (eg bugid #19022) */
-       if (!SvIsCOW(PL_curpad[po]))
-           SvREADONLY_off(PL_curpad[po]);      /* could be a freed constant */
-#endif
     }
     if ((I32)po < PL_padix)
        PL_padix = po - 1;
@@ -1646,7 +1646,7 @@ Perl_cv_clone(pTHX_ CV *proto)
     CvPADLIST(cv) = pad_new(padnew_CLONE|padnew_SAVE);
 
     av_fill(PL_comppad, fpad);
-    for (ix = fname; ix >= 0; ix--)
+    for (ix = fname; ix > 0; ix--)
        av_store(PL_comppad_name, ix, SvREFCNT_inc(pname[ix]));
 
     PL_curpad = AvARRAY(PL_comppad);