]> git.ipfire.org Git - thirdparty/git.git/blobdiff - grep.c
grep: work around UTF-8 related JIT bug in PCRE2 <= 10.34
[thirdparty/git.git] / grep.c
diff --git a/grep.c b/grep.c
index 1687f65b64fdf6a229a1ab2e37d7c7ac8955a5b6..00b3cf0e1872f6dabe6428b3283540b63b7ef939 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -295,6 +295,15 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
        if (!opt->ignore_locale && is_utf8_locale() && !literal)
                options |= (PCRE2_UTF | PCRE2_UCP | PCRE2_MATCH_INVALID_UTF);
 
+#ifndef GIT_PCRE2_VERSION_10_35_OR_HIGHER
+       /*
+        * Work around a JIT bug related to invalid Unicode character handling
+        * fixed in 10.35:
+        * https://github.com/PCRE2Project/pcre2/commit/c21bd977547d
+        */
+       options &= ~PCRE2_UCP;
+#endif
+
 #ifndef GIT_PCRE2_VERSION_10_36_OR_HIGHER
        /* Work around https://bugs.exim.org/show_bug.cgi?id=2642 fixed in 10.36 */
        if (PCRE2_MATCH_INVALID_UTF && options & (PCRE2_UTF | PCRE2_CASELESS))