From: Ilya Zakharevich Date: Fri, 17 Jul 1998 13:55:38 +0000 (-0400) Subject: fix flawed substitution-loop detection on zero-length matches X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2beec16e955b826c44eaea93f62e1ff554d4c42a;p=p5sagit%2Fp5-mst-13.2.git fix flawed substitution-loop detection on zero-length matches Message-Id: <199807171755.NAA27720@monk.mps.ohio-state.edu> Subject: [PATCH 5.004_72] Substitution loop in devel branch p4raw-id: //depot/perl@1560 --- diff --git a/pp_hot.c b/pp_hot.c index 3ecb5b3..d2a7af5 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1590,7 +1590,9 @@ PP(pp_subst) DIE("panic: do_subst"); strend = s + len; - maxiters = (strend - s) + 10; + maxiters = 2*(strend - s) + 10; /* We can match twice at each + position, once with zero-length, + second time with non-zero. */ if (!rx->prelen && curpm) { pm = curpm; diff --git a/t/op/subst.t b/t/op/subst.t index 57a956d..2d42eeb 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -6,7 +6,7 @@ BEGIN { @INC = '../lib' if -d '../lib'; } -print "1..70\n"; +print "1..71\n"; $x = 'foo'; $_ = "x"; @@ -302,3 +302,7 @@ s{ \d+ \b [,.;]? (?{ 'digits' }) }{$^R}xg; print ($_ eq $foo ? "ok 70\n" : "not ok 70\n#'$_'\n#'$foo'\n"); +$_ = 'x' x 20; +s/\d*|x/<$&>/g; +$foo = '<>' . ('<>' x 20) ; +print ($_ eq $foo ? "ok 71\n" : "not ok 71\n#'$_'\n#'$foo'\n");