summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.compulink.co.uk>1997-06-14 16:14:33 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit44ed422101809141bc33c2b85c1cff357de4d7bf (patch)
tree4aeae3e483b2fc276f5fd502d8b239bf11f7c1dd /gv.c
parente09f3e01ccd721309f0eb0aae224d84db2e8436a (diff)
downloadperl-44ed422101809141bc33c2b85c1cff357de4d7bf.tar.gz
Avoid core dump on some paren'd regexp matches
In article <199706260526.XAA01060@lunkwill.ml.org> Jason wrote: :This script causes Perl to dump core with a segmentation fault under :Linux as well as HP-UX. Here's the script: : :#!/usr/local/bin/perl :@justalist = ("foo\nbar" =~ /(\s|(foo)|(bar))*/ ); It does the same under 5.004_01. The reason is that on the second match it tried to match (foo) and succeeded, leaving startp[2] and endp[2] pointing to the beginning and end of the matched 'foo'. On the third match, it tried to match (foo) and failed; in doing so, it overwrote startp[2] with the startpoint it was trying to match ('bar'), but left endp[2] unaltered. If that third match had failed, no problem would occur - it would restore startp[] and endp[] from saved copies. However, because the third match then succeeded on the final alternate the modified startp[] and endp[] were retained, leaving a mismatched pair of values for $2. The solution depends on what the answer should be - one interpretation is that, since (foo) failed to match the last time it was tried, the results should be ('bar', undef, 'bar'). The first patch below effects this. Alternatively, you could say that it was more correct and/or more useful for it to return the last successful match on (foo), in which case you want the rather more complicated second patch below. I'm not an expert on this stuff - Ilya, can you take a look at these patches and tell me how broken they are, please? My own feeling is that the second interpretation is more useful, but I have much less confidence in the completeness of my patch for this. No test cases supplied at this stage: Jason's testcase above should suffice for the moment. Perl passes all tests here with either patch. p5p-msgid: 199706261236.NAA03472@crypt.compulink.co.uk
Diffstat (limited to 'gv.c')
0 files changed, 0 insertions, 0 deletions