This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #130262) split scalar context stack overflow fix
authorTony Cook <tony@develop-help.com>
Mon, 5 Dec 2016 00:48:14 +0000 (11:48 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 16 Jan 2017 04:43:31 +0000 (15:43 +1100)
pp_split didn't ensure there was space for its return value
in scalar context.

pp.c
t/op/split.t

diff --git a/pp.c b/pp.c
index adda6c9..657abf7 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -6142,7 +6142,7 @@ PP(pp_split)
     }
 
     GETTARGET;
-    PUSHi(iters);
+    XPUSHi(iters);
     RETURN;
 }
 
index 81c908e..d60bcaf 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     set_up_inc('../lib');
 }
 
-plan tests => 162;
+plan tests => 163;
 
 $FS = ':';
 
@@ -629,3 +629,7 @@ is "@a", '1 2 3', 'assignment to split-to-array (stacked)';
     my @a = split ' ', $s;
     is (+@a, 0, "empty utf8 string");
 }
+
+fresh_perl_is(<<'CODE', '', {}, "scalar split stack overflow");
+map{int"";split//.0>60for"0000000000000000"}split// for"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+CODE