From d46b78c674c5ad23656932e71fea9369ee8ac4df Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 20 Oct 2012 16:55:26 -0600 Subject: [PATCH] PATCH: [perl #115242]: /m and regex optimizer bug. This commit turns off string length checking for /m. A string longer than the calculated maximum can match under /m because, for example, trailing new lines in it can come after the $ anchor. A test for this condition is in the next commit. --- regexec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/regexec.c b/regexec.c index f01b605..a5451b6 100644 --- a/regexec.c +++ b/regexec.c @@ -660,8 +660,12 @@ Perl_re_intuit_start(pTHX_ REGEXP * const rx, SV *sv, char *strpos, DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Not at start...\n")); goto fail; } - if (prog->check_offset_min == prog->check_offset_max && - !(prog->extflags & RXf_CANY_SEEN)) { + if (prog->check_offset_min == prog->check_offset_max + && !(prog->extflags & RXf_CANY_SEEN) + && ! multiline) /* /m can cause \n's to match that aren't + accounted for in the string max length. + See [perl #115242] */ + { /* Substring at constant offset from beg-of-str... */ I32 slen; -- 2.7.4