From: Dave Mitchell Date: Mon, 3 May 2004 17:44:44 +0000 (+0000) Subject: [perl #28938] split could leave an array without &PL_sv_undef X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3a8873fee48db53bdab7f38729038b2eab97f0b;p=p5sagit%2Fp5-mst-13.2.git [perl #28938] split could leave an array without &PL_sv_undef in the unused elements p4raw-id: //depot/perl@22774 --- diff --git a/pp.c b/pp.c index 1a35902..a3e56d3 100644 --- a/pp.c +++ b/pp.c @@ -4636,7 +4636,7 @@ PP(pp_split) if (TOPs && !make_mortal) sv_2mortal(TOPs); iters--; - SP--; + *SP-- = &PL_sv_undef; } } diff --git a/t/op/split.t b/t/op/split.t index 957da24..31a2f51 100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 54; +plan tests => 55; $FS = ':'; @@ -289,3 +289,16 @@ ok(@ary == 3 && $n = @a = split /,/,$p; is ($n, 0, '#21765 - pmreplroot hack used to return undef for 0 iters'); } + +{ + # [perl #28938] + # assigning off the end of the array after a split could leave garbage + # in the inner elements + + my $x; + @a = split /,/, ',,,,,'; + $a[3]=1; + $x = \$a[2]; + is (ref $x, 'SCALAR', '#28938 - garbage after extend'); +} +