[Pcre-svn] [613] code/trunk: Fix crash in pcre2test when dis…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [613] code/trunk: Fix crash in pcre2test when displaying a wide character with a locale set.
Revision: 613
          http://www.exim.org/viewvc/pcre2?view=rev&revision=613
Author:   ph10
Date:     2016-12-08 18:56:24 +0000 (Thu, 08 Dec 2016)
Log Message:
-----------
Fix crash in pcre2test when displaying a wide character with a locale set.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2test.c
    code/trunk/testdata/testinput5
    code/trunk/testdata/testoutput5


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2016-12-08 17:55:26 UTC (rev 612)
+++ code/trunk/ChangeLog    2016-12-08 18:56:24 UTC (rev 613)
@@ -201,7 +201,10 @@
 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
--------------------------


Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2016-12-08 17:55:26 UTC (rev 612)
+++ code/trunk/src/pcre2test.c    2016-12-08 18:56:24 UTC (rev 613)
@@ -211,7 +211,7 @@
 #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 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 @@
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 @@
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);

Modified: code/trunk/testdata/testinput5
===================================================================
--- code/trunk/testdata/testinput5    2016-12-08 17:55:26 UTC (rev 612)
+++ code/trunk/testdata/testinput5    2016-12-08 18:56:24 UTC (rev 613)
@@ -1746,4 +1746,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

Modified: code/trunk/testdata/testoutput5
===================================================================
--- code/trunk/testdata/testoutput5    2016-12-08 17:55:26 UTC (rev 612)
+++ code/trunk/testdata/testoutput5    2016-12-08 18:56:24 UTC (rev 613)
@@ -4190,4 +4190,17 @@


/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