From: Stephen McCamant Date: Tue, 28 Jul 1998 22:18:25 +0000 (-0500) Subject: avoid reusing foreach itervar if magic got tacked onto it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39ca2bb7cd8f975c0e460242f7deaed80ab31ddc;p=p5sagit%2Fp5-mst-13.2.git avoid reusing foreach itervar if magic got tacked onto it Message-ID: <13758.36756.215424.719750@alias-2.pr.mcs.net> Subject: [PATCH] Re: pos() resetting changed with 5.005? p4raw-id: //depot/maint-5.005/perl@1682 --- diff --git a/pp_hot.c b/pp_hot.c index d0fdbfc..29f6542 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1460,7 +1460,9 @@ PP(pp_iter) char *max = SvPV((SV*)av, maxlen); if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) { #ifndef USE_THREADS /* don't risk potential race */ - if (SvREFCNT(*cx->blk_loop.itervar) == 1) { + if (SvREFCNT(*cx->blk_loop.itervar) == 1 + && !SvMAGICAL(*cx->blk_loop.itervar)) + { /* safe to reuse old SV */ sv_setsv(*cx->blk_loop.itervar, cur); } @@ -1486,7 +1488,9 @@ PP(pp_iter) RETPUSHNO; #ifndef USE_THREADS /* don't risk potential race */ - if (SvREFCNT(*cx->blk_loop.itervar) == 1) { + if (SvREFCNT(*cx->blk_loop.itervar) == 1 + && !SvMAGICAL(*cx->blk_loop.itervar)) + { /* safe to reuse old SV */ sv_setiv(*cx->blk_loop.itervar, cx->blk_loop.iterix++); }