diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-03-22 14:09:05 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-03-22 14:09:45 -0700 |
commit | dfcd2c9cc8d581c17e876707344b6f44c1bd0873 (patch) | |
tree | 690b1adcc611953787f791d0900da79665ce2741 /src | |
parent | 0ca5dcc1c57bcd24ea18628444340faff222ef64 (diff) | |
download | grep-dfcd2c9cc8d581c17e876707344b6f44c1bd0873.tar.gz |
grep: work around another potential PCRE2 bug
Potential problem reported by René Scharfe in:
https://lore.kernel.org/git/99b0adb6-26ba-293c-3a8f-679f59e7cb4d@web.de/T
* src/pcresearch.c (Pcompile): Mimic git grep’s workarounds
for PCRE2 bugs more closely; this is more conservative.
Diffstat (limited to 'src')
-rw-r--r-- | src/pcresearch.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c index 0cf804d6..6947838a 100644 --- a/src/pcresearch.c +++ b/src/pcresearch.c @@ -154,15 +154,16 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact) #ifdef PCRE2_MATCH_INVALID_UTF /* Consider invalid UTF-8 as a barrier, instead of error. */ flags |= PCRE2_MATCH_INVALID_UTF; - -# if ! (10 < PCRE2_MAJOR + (36 <= PCRE2_MINOR)) - /* Work around PCRE2 bug 2642. */ - if (flags & PCRE2_CASELESS) - flags |= PCRE2_NO_START_OPTIMIZE; -# endif #endif } +#if defined PCRE2_MATCH_INVALID_UTF && !(10 < PCRE2_MAJOR + (36 <= PCRE2_MINOR)) + /* Work around PCRE2 bug 2642, and another bug reportedly fixed in + PCRE2 commit e0c6029a62db9c2161941ecdf459205382d4d379. */ + if (flags & (PCRE2_UTF | PCRE2_CASELESS)) + flags |= PCRE2_NO_START_OPTIMIZE; +#endif + /* FIXME: Remove this restriction. */ if (rawmemchr (pattern, '\n') != patlim) die (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern")); |