From: Rafael Garcia-Suarez Date: Tue, 24 Feb 2004 22:34:06 +0000 (+0000) Subject: Fix a segfault during optree construction. (bug #27024) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1548254d1365ef0342d5b64bb1fd1d996c1f70f;p=p5sagit%2Fp5-mst-13.2.git Fix a segfault during optree construction. (bug #27024) p4raw-id: //depot/perl@22371 --- diff --git a/op.c b/op.c index c5b2e83..4bd252c 100644 --- a/op.c +++ b/op.c @@ -3577,6 +3577,10 @@ Perl_newLOOPOP(pTHX_ I32 flags, I32 debuggable, OP *expr, OP *block) } } + /* if block is null, the next append_elem() would put UNSTACK, a scalar + * op, in listop. This is wrong. [perl #27024] */ + if (!block) + block = newOP(OP_NULL, 0); listop = append_elem(OP_LINESEQ, block, newOP(OP_UNSTACK, 0)); o = new_logop(OP_AND, 0, &expr, &listop); diff --git a/t/comp/parser.t b/t/comp/parser.t index e59fec6..2c25807 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -9,7 +9,7 @@ BEGIN { } require "./test.pl"; -plan( tests => 43 ); +plan( tests => 44 ); eval '%@x=0;'; like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' ); @@ -147,3 +147,11 @@ EOF eval q{ sub f { @a=@b=@c; {use} } }; like( $@, qr/syntax error/, "use without body" ); } + +# Bug #27024 +{ + # this used to segfault (because $[=1 is optimized away to a null block) + my $x; + $[ = 1 while $x; + pass(); +}