This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In Perl_cv_undef(), only check potential pads against PL_comppad
authorNicholas Clark <nick@ccl4.org>
Wed, 17 Nov 2010 11:39:06 +0000 (11:39 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 17 Nov 2010 11:39:06 +0000 (11:39 +0000)
Don't even try checking the address of the pad name AV against PL_comppad, and
don't try checking the address of pad AVs against PL_comppad_name. Neither will
ever match.

pad.c

diff --git a/pad.c b/pad.c
index 06cadbb..7d7b5eb 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)));