Fix compile loop for subroutine reference after class such as [^\ff].

This commit is contained in:
Philip.Hazel 2015-02-06 17:51:55 +00:00
parent ad452f4036
commit 2e36497404
4 changed files with 36 additions and 0 deletions

View File

@ -62,6 +62,9 @@ infinite loop. Now it generates an "internal error" error. This is a tidyup,
not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an
undefined outcome. undefined outcome.
12. A UTF pattern containing a "not" match of a non-ASCII character and a
subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.
Version 10.00 05-January-2015 Version 10.00 05-January-2015
----------------------------- -----------------------------

View File

@ -2353,32 +2353,60 @@ for (;;)
{ {
case OP_CHAR: case OP_CHAR:
case OP_CHARI: case OP_CHARI:
case OP_NOT:
case OP_NOTI:
case OP_EXACT: case OP_EXACT:
case OP_EXACTI: case OP_EXACTI:
case OP_NOTEXACT:
case OP_NOTEXACTI:
case OP_UPTO: case OP_UPTO:
case OP_UPTOI: case OP_UPTOI:
case OP_NOTUPTO:
case OP_NOTUPTOI:
case OP_MINUPTO: case OP_MINUPTO:
case OP_MINUPTOI: case OP_MINUPTOI:
case OP_NOTMINUPTO:
case OP_NOTMINUPTOI:
case OP_POSUPTO: case OP_POSUPTO:
case OP_POSUPTOI: case OP_POSUPTOI:
case OP_NOTPOSUPTO:
case OP_NOTPOSUPTOI:
case OP_STAR: case OP_STAR:
case OP_STARI: case OP_STARI:
case OP_NOTSTAR:
case OP_NOTSTARI:
case OP_MINSTAR: case OP_MINSTAR:
case OP_MINSTARI: case OP_MINSTARI:
case OP_NOTMINSTAR:
case OP_NOTMINSTARI:
case OP_POSSTAR: case OP_POSSTAR:
case OP_POSSTARI: case OP_POSSTARI:
case OP_NOTPOSSTAR:
case OP_NOTPOSSTARI:
case OP_PLUS: case OP_PLUS:
case OP_PLUSI: case OP_PLUSI:
case OP_NOTPLUS:
case OP_NOTPLUSI:
case OP_MINPLUS: case OP_MINPLUS:
case OP_MINPLUSI: case OP_MINPLUSI:
case OP_NOTMINPLUS:
case OP_NOTMINPLUSI:
case OP_POSPLUS: case OP_POSPLUS:
case OP_POSPLUSI: case OP_POSPLUSI:
case OP_NOTPOSPLUS:
case OP_NOTPOSPLUSI:
case OP_QUERY: case OP_QUERY:
case OP_QUERYI: case OP_QUERYI:
case OP_NOTQUERY:
case OP_NOTQUERYI:
case OP_MINQUERY: case OP_MINQUERY:
case OP_MINQUERYI: case OP_MINQUERYI:
case OP_NOTMINQUERY:
case OP_NOTMINQUERYI:
case OP_POSQUERY: case OP_POSQUERY:
case OP_POSQUERYI: case OP_POSQUERYI:
case OP_NOTPOSQUERY:
case OP_NOTPOSQUERYI:
if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]); if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
break; break;
} }

2
testdata/testinput5 vendored
View File

@ -1636,4 +1636,6 @@
/(?<=abc)(|def)/g,utf,replace=<$0> /(?<=abc)(|def)/g,utf,replace=<$0>
123abcáyzabcdef789abcሴqr 123abcáyzabcdef789abcሴqr
/[^\xff]((?1))/utf,debug
# End of testinput5 # End of testinput5

View File

@ -4006,4 +4006,7 @@ Subject length lower bound = 1
123abcáyzabcdef789abcሴqr 123abcáyzabcdef789abcሴqr
4: 123abc<>\x{e1}yzabc<><def>789abc<>\x{1234}qr 4: 123abc<>\x{e1}yzabc<><def>789abc<>\x{1234}qr
/[^\xff]((?1))/utf,debug
Failed: error 140 at offset 11: recursion could loop indefinitely
# End of testinput5 # End of testinput5