Fix \g+ bug when the number that follows is too big.

This commit is contained in:
Philip.Hazel 2017-01-31 17:15:30 +00:00
parent 56a8ada12d
commit 4311f49d0e
4 changed files with 25 additions and 4 deletions

View File

@ -330,7 +330,7 @@ AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT
modules.
52. Minor fixed to pcre2grep from Jason Hood:
* fixes some spacing;
* fixed some spacing;
* Windows doesn't usually use single quotes, so I've added a define
to use appropriate quotes [in an example];
* LC_ALL was displayed as "LCC_ALL";

View File

@ -1220,9 +1220,20 @@ BOOL yield = FALSE;
*errorcodeptr = 0;
if (allow_sign >= 0 && ptr < ptrend &&
(*ptr == CHAR_PLUS || *ptr == CHAR_MINUS))
sign = (*ptr++ == CHAR_MINUS)? -1 : +1;
if (allow_sign >= 0 && ptr < ptrend)
{
if (*ptr == CHAR_PLUS)
{
sign = +1;
max_value -= allow_sign;
ptr++;
}
else if (*ptr == CHAR_MINUS)
{
sign = -1;
ptr++;
}
}
if (ptr >= ptrend || !IS_DIGIT(*ptr)) return FALSE;
while (ptr < ptrend && IS_DIGIT(*ptr))

4
testdata/testinput2 vendored
View File

@ -4959,4 +4959,8 @@ a)"xI
/abcd/auto_callout
abcd\=callout_error=255:2
/()(\g+65534)/
/()(\g+65533)/
# End of testinput2

View File

@ -15446,6 +15446,12 @@ Failed: error 128 at offset 11: assertion expected after (?( or (?(?C)
+1 ^^ b
Failed: error -37: callout error code
/()(\g+65534)/
Failed: error 161 at offset 11: group number is too big
/()(\g+65533)/
Failed: error 115 at offset 10: reference to non-existent subpattern
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data