summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorStephen Potter <spp@psa.pencom.com>1997-03-28 15:38:30 -0600
committerChip Salzenberg <chip@atlantic.net>1997-03-26 07:04:34 +1200
commitbb20fd4482d9bb7fc51487521e4e74598d487279 (patch)
tree5f3fb7b77c7b863359731fb85c72fbf8f1d38af6 /regcomp.c
parenteb79544ff58c74c06888e5611739331fa5e91f32 (diff)
downloadperl-bb20fd4482d9bb7fc51487521e4e74598d487279.tar.gz
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?= <Markus.Th eissinger@gmd.de> 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
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 4c34b59c61..5dad7d78e2 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);