From: Marcus Holland-Moritz Date: Fri, 5 Mar 2004 15:13:53 +0000 (+0100) Subject: Re: Strange segfault X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f63a7829490e7c2b14422ea9863ba16725d1ead;p=p5sagit%2Fp5-mst-13.2.git Re: Strange segfault Message-ID: <20040305151353.5f3e913c@r2d2> p4raw-id: //depot/perl@22443 --- diff --git a/pp_ctl.c b/pp_ctl.c index fa2c87c..fd98698 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1056,6 +1056,7 @@ PP(pp_flip) an exception for .."0" [#18165]). AMS 20021031. */ #define RANGE_IS_NUMERIC(left,right) ( \ + (!SvOK(left) && !SvOK(right)) || \ SvNIOKp(left) || (SvOK(left) && !SvPOKp(left)) || \ SvNIOKp(right) || (SvOK(right) && !SvPOKp(right)) || \ (looks_like_number(left) && SvPOKp(left) && *SvPVX(left) != '0' && \ @@ -1797,8 +1798,11 @@ PP(pp_enteriter) cx->blk_loop.iterix = SvIV(sv); cx->blk_loop.itermax = SvIV((SV*)cx->blk_loop.iterary); } - else + else { + STRLEN n_a; cx->blk_loop.iterlval = newSVsv(sv); + SvPV_force(cx->blk_loop.iterlval,n_a); + } } } else { diff --git a/t/op/range.t b/t/op/range.t index d54c96d..d92be7a 100755 --- a/t/op/range.t +++ b/t/op/range.t @@ -1,6 +1,6 @@ #!./perl -print "1..25\n"; +print "1..30\n"; print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; @@ -89,3 +89,19 @@ print join(":","".."B") eq '' ? "ok 22\n" : "not ok 22\n"; print join(":",undef.."B") eq '' ? "ok 23\n" : "not ok 23\n"; print join(":","B".."") eq '' ? "ok 24\n" : "not ok 24\n"; print join(":","B"..undef) eq '' ? "ok 25\n" : "not ok 25\n"; + +# undef..undef used to segfault and should be 0..0 +print join(":",undef..undef) eq '0' ? "ok 26\n" : "not ok 26\n"; + +# also test undef in foreach loops +@foo=(); push @foo, $_ for undef..2; +print join(":",@foo) eq '0:1:2' ? "ok 27\n" : "not ok 27\n"; + +@foo=(); push @foo, $_ for -2..undef; +print join(":",@foo) eq '-2:-1:0' ? "ok 28\n" : "not ok 28\n"; + +@foo=(); push @foo, $_ for undef.."B"; +print join(":",@foo) eq '' ? "ok 29\n" : "not ok 29\n"; + +@foo=(); push @foo, $_ for "B"..undef; +print join(":",@foo) eq '' ? "ok 30\n" : "not ok 30\n";