Fix caseless minimizing back reference bug when heap in use for recursion.

This commit is contained in:
Philip.Hazel 2016-12-10 14:59:24 +00:00
parent 7914fa82a9
commit a98121a212
4 changed files with 17 additions and 1 deletions

View File

@ -211,6 +211,13 @@ dereference).
33. If the starting offset was specified as greater than the subject length in 33. If the starting offset was specified as greater than the subject length in
a call to pcre2_substitute() an out-of-bounds memory reference could occur. a call to pcre2_substitute() an out-of-bounds memory reference could occur.
34. When PCRE2 was compiled to use the heap instead of the stack for recursive
calls to match(), a repeated minimizing caseless back reference, or a
maximizing one where the two cases had different numbers of code units,
followed by a caseful back reference, could lose the caselessness of the first
repeated back reference (example: /(Z)(a)\2{1,2}?(?-i)\1X/i should match ZaAAZX
but didn't).
Version 10.22 29-July-2016 Version 10.22 29-July-2016
-------------------------- --------------------------

View File

@ -586,7 +586,6 @@ uint32_t c; /* Character values not kept over RMATCH() calls */
BOOL utf; /* Local copy of UTF flag for speed */ BOOL utf; /* Local copy of UTF flag for speed */
BOOL minimize, possessive; /* Quantifier options */ BOOL minimize, possessive; /* Quantifier options */
BOOL caseless;
int condcode; int condcode;
/* When recursion is not being used, all "local" variables that have to be /* When recursion is not being used, all "local" variables that have to be
@ -724,6 +723,7 @@ still need to be preserved over recursive calls of match(). These macros define
the alternative names that are used. */ the alternative names that are used. */
#define allow_zero cur_is_word #define allow_zero cur_is_word
#define caseless cur_is_word
#define cbegroup condition #define cbegroup condition
#define code_offset codelink #define code_offset codelink
#define condassert condition #define condassert condition

3
testdata/testinput1 vendored
View File

@ -5815,4 +5815,7 @@ ef) x/x,mark
/(?s)(?=.*?)b/ /(?s)(?=.*?)b/
aabc aabc
/(Z)(a)\2{1,2}?(?-i)\1X/i
ZaAAZX
# End of testinput1 # End of testinput1

View File

@ -9289,4 +9289,10 @@ No match
aabc aabc
0: b 0: b
/(Z)(a)\2{1,2}?(?-i)\1X/i
ZaAAZX
0: ZaAAZX
1: Z
2: a
# End of testinput1 # End of testinput1