From: Stephen Potter Date: Fri, 28 Mar 1997 21:38:30 +0000 (-0600) Subject: Die on patterns that will match empty string forever X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb20fd4482d9bb7fc51487521e4e74598d487279;p=p5sagit%2Fp5-mst-13.2.git Die on patterns that will match empty string forever Subject: Re: Segementation fault in perl5.001 and 5.003 Strange sunspot activity caused =?iso-8859-1?Q?Markus_Thei=DFinger?= to write: | Hi, | | perl -e '$_=3D" 2"; print STDOUT /^(\s*(\))*)+$/;' | | produces a segmentation fault [snips] Confirmed on 3_95. I'm surprised this kind of thing lasted this long. Actually, I could have sworn someone fixed this awhile back. I suppose one of the regulars could probably provide a better patch. Works fine on 4.036, this patch returns it to 4.036 functionality. p5p-msgid: 199703282138.PAA28311@psa.pencom.com --- diff --git a/regcomp.c b/regcomp.c index 4c34b59..5dad7d7 100644 --- a/regcomp.c +++ b/regcomp.c @@ -697,6 +697,10 @@ I32 *flagp; *flagp = flags; return(ret); } + + if (!(flags&HASWIDTH) && op != '?') + FAIL("regexp *+ operand could be empty"); + nextchar(); *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);