From 8a8d0ced69e8f6039c2257a26a6a5698956d5a96 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Thu, 22 Oct 2015 15:49:54 +0000 Subject: [PATCH] Fix spurious error in pcre2test when single-letter modifiers at the end of a line have trailing spaces. --- ChangeLog | 3 +++ src/pcre2test.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7a1f0fb..82144ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -210,6 +210,9 @@ erroneous error "\ at end of pattern". errors or other strange effects if compiled in UCP mode. Found with libFuzzer and AddressSanitizer. +61. Whitespace at the end of a pcre2test pattern line caused a spurious error +message if there were only single-character modifiers. It should be ignored. + Version 10.20 30-June-2015 -------------------------- diff --git a/src/pcre2test.c b/src/pcre2test.c index 88c61eb..d13f719 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -3111,7 +3111,11 @@ for (;;) /* Find the end of the item; lose trailing whitespace at end of line. */ for (ep = p; *ep != 0 && *ep != ','; ep++); - if (*ep == 0) while (ep > p && isspace(ep[-1])) ep--; + if (*ep == 0) + { + while (ep > p && isspace(ep[-1])) ep--; + *ep = 0; + } /* Remember if the first character is '-'. */