Skip to content

Commit d35cd54

Browse files
committed
Merge branch 'mk/workaround-pcre-jit-ucp-bug'
A recent-ish change to allow unicode character classes to be used with "grep -P" triggered a JIT bug in older pcre2 libraries. The problematic change in Git built with these older libraries has been disabled to work around the bug. * mk/workaround-pcre-jit-ucp-bug: grep: work around UTF-8 related JIT bug in PCRE2 <= 10.34
2 parents a15b845 + 14b9a04 commit d35cd54

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

grep.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
321321
if (!opt->ignore_locale && is_utf8_locale() && !literal)
322322
options |= (PCRE2_UTF | PCRE2_UCP | PCRE2_MATCH_INVALID_UTF);
323323

324+
#ifndef GIT_PCRE2_VERSION_10_35_OR_HIGHER
325+
/*
326+
* Work around a JIT bug related to invalid Unicode character handling
327+
* fixed in 10.35:
328+
* https://github.com/PCRE2Project/pcre2/commit/c21bd977547d
329+
*/
330+
options &= ~PCRE2_UCP;
331+
#endif
332+
324333
#ifndef GIT_PCRE2_VERSION_10_36_OR_HIGHER
325334
/* Work around https://bugs.exim.org/show_bug.cgi?id=2642 fixed in 10.36 */
326335
if (PCRE2_MATCH_INVALID_UTF && options & (PCRE2_UTF | PCRE2_CASELESS))

grep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#if (PCRE2_MAJOR >= 10 && PCRE2_MINOR >= 36) || PCRE2_MAJOR >= 11
88
#define GIT_PCRE2_VERSION_10_36_OR_HIGHER
99
#endif
10+
#if (PCRE2_MAJOR >= 10 && PCRE2_MINOR >= 35) || PCRE2_MAJOR >= 11
11+
#define GIT_PCRE2_VERSION_10_35_OR_HIGHER
12+
#endif
1013
#if (PCRE2_MAJOR >= 10 && PCRE2_MINOR >= 34) || PCRE2_MAJOR >= 11
1114
#define GIT_PCRE2_VERSION_10_34_OR_HIGHER
1215
#endif

0 commit comments

Comments
 (0)