This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #115242]: /m and regex optimizer bug.
authorKarl Williamson <public@khwilliamson.com>
Sat, 20 Oct 2012 22:55:26 +0000 (16:55 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 21 Oct 2012 04:13:38 +0000 (22:13 -0600)
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

index f01b605..a5451b6 100644 (file)
--- 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;