This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #24254] Attempt to free unreferenced scalar
authorChris Heath <chris@heathens.co.nz>
Sun, 6 Nov 2005 20:08:05 +0000 (12:08 -0800)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 7 Nov 2005 09:58:26 +0000 (09:58 +0000)
From: "Chris Heath via RT" <perlbug-followup@perl.org>
Message-ID: <rt-3.0.11-24254-123984.4.44134155985068@perl.org>

p4raw-id: //depot/perl@26027

cop.h

diff --git a/cop.h b/cop.h
index f2e4463..47c2375 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -407,9 +407,14 @@ struct block_loop {
 #define POPLOOP(cx)                                                    \
        SvREFCNT_dec(cx->blk_loop.iterlval);                            \
        if (CxITERVAR(cx)) {                                            \
-           SV **s_v_p = CxITERVAR(cx);                                 \
-           sv_2mortal(*s_v_p);                                         \
-           *s_v_p = cx->blk_loop.itersave;                             \
+            if (SvPADMY(cx->blk_loop.itersave)) {                      \
+               SV **s_v_p = CxITERVAR(cx);                             \
+               sv_2mortal(*s_v_p);                                     \
+               *s_v_p = cx->blk_loop.itersave;                         \
+           }                                                           \
+           else {                                                      \
+               SvREFCNT_dec(cx->blk_loop.itersave);                    \
+           }                                                           \
        }                                                               \
        if (cx->blk_loop.iterary && cx->blk_loop.iterary != PL_curstack)\
            SvREFCNT_dec(cx->blk_loop.iterary);