diff --git a/ChangeLog b/ChangeLog index 992c7fe..5446209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -201,6 +201,9 @@ pcre2test for testing it. 30. Fix out-of-bounds read for partial matching of /./ against an empty string when the newline type is CRLF. +31. Fix a bug in pcre2test that caused a crash when a locale was set either in +the current pattern or a previous one and a wide character was matched. + Version 10.22 29-July-2016 -------------------------- diff --git a/src/pcre2test.c b/src/pcre2test.c index 988d9f9..19b5651 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -211,7 +211,7 @@ systems that differ in their output from isprint() even in the "C" locale. */ #define PRINTABLE(c) ((c) >= 32 && (c) < 127) #endif -#define PRINTOK(c) ((locale_tables != NULL)? isprint(c) : PRINTABLE(c)) +#define PRINTOK(c) ((use_tables != NULL && c < 256)? isprint(c) : PRINTABLE(c)) /* We have to include some of the library source files because we need to use some of the macros, internal structure definitions, and other internal @@ -833,6 +833,7 @@ static regex_t preg = { NULL, NULL, 0, 0, 0 }; static int *dfa_workspace = NULL; static const uint8_t *locale_tables = NULL; +static const uint8_t *use_tables = NULL; static uint8_t locale_name[32]; /* We need buffers for building 16/32-bit strings; 8-bit strings don't need @@ -4547,7 +4548,6 @@ process_pattern(void) BOOL utf; uint32_t k; uint8_t *p = buffer; -const uint8_t *use_tables; unsigned int delimiter = *p++; int errorcode; void *use_pat_context; @@ -5058,8 +5058,8 @@ if ((pat_patctl.control2 & CTL_NL_SET) == 0 && local_newline_default != 0) SETFLD(pat_context, newline_convention, local_newline_default); } -/* The nullcontext modifier is used to test calling pcre2_compile() with a NULL -context. */ +/* The null_context modifier is used to test calling pcre2_compile() with a +NULL context. */ use_pat_context = ((pat_patctl.control & CTL_NULLCONTEXT) != 0)? NULL : PTR(pat_context); diff --git a/testdata/testinput5 b/testdata/testinput5 index d9e606d..65a2698 100644 --- a/testdata/testinput5 +++ b/testdata/testinput5 @@ -1744,4 +1744,15 @@ /XȀ/x,utf +# These three test a bug fix that was not clearing up after a locale setting +# when the test or a subsequent one matched a wide character. + +//locale=C + +/[\P{Yi}]/utf +\x{2f000} + +/[\P{Yi}]/utf,locale=C +\x{2f000} + # End of testinput5 diff --git a/testdata/testoutput5 b/testdata/testoutput5 index 59cd744..c1413a8 100644 --- a/testdata/testoutput5 +++ b/testdata/testoutput5 @@ -4188,4 +4188,17 @@ Failed: error 125 at offset 2: lookbehind assertion is not fixed length /XȀ/x,utf +# These three test a bug fix that was not clearing up after a locale setting +# when the test or a subsequent one matched a wide character. + +//locale=C + +/[\P{Yi}]/utf +\x{2f000} + 0: \x{2f000} + +/[\P{Yi}]/utf,locale=C +\x{2f000} + 0: \x{2f000} + # End of testinput5