This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #118175] avoid overflowing a pointer for repeated EXACT nodes
authorTony Cook <tony@develop-help.com>
Tue, 28 May 2013 10:43:28 +0000 (20:43 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 3 Jun 2013 12:05:27 +0000 (22:05 +1000)
regexec.c

index 4fc9444..c39b9f6 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -6724,7 +6724,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
          * can use UTF8_IS_INVARIANT() even if the pattern isn't UTF-8, as it's
          * true iff it doesn't matter if the argument is in UTF-8 or not */
         if (UTF8_IS_INVARIANT(c) || (! utf8_target && ! reginfo->is_utf8_pat)) {
-            if (utf8_target && scan + max < loceol) {
+            if (utf8_target && loceol - scan > max) {
                 /* We didn't adjust <loceol> because is UTF-8, but ok to do so,
                  * since here, to match at all, 1 char == 1 byte */
                 loceol = scan + max;