re_intuit_start(): MBOL limit in chars not bytes
authorDavid Mitchell <davem@iabyn.com>
Fri, 7 Feb 2014 21:11:28 +0000 (21:11 +0000)
committerDavid Mitchell <davem@iabyn.com>
Sat, 8 Feb 2014 14:04:55 +0000 (14:04 +0000)
The calculation for the maximum position \n should be searched for,
strend - prog->minlen, is currently done in bytes. Change it to
chars for correctness. It probably doesn't matter at the moment, because
any overshoot in \n will still fail other constraints (which *do* calculate
the end-point correctly). But in the future that might change, and we
don't want any surprises.

regexec.c

index 0634a8b..f9cfc89 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1104,7 +1104,7 @@ Perl_re_intuit_start(pTHX_
          */
 
         t = (char *)memchr(rx_origin, '\n',
-                        (strend - prog->minlen) - rx_origin);
+                        HOP3c(strend, - prog->minlen, strpos) - rx_origin);
         if (!t) {
             DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
                             "  Did not find /%s^%s/m...\n",