Skip to content

Commit 674ad93

Browse files
avargitster
authored andcommitted
grep: fix erroneously copy/pasted variable in check/assert pattern
Fix an erroneously copy/pasted check for the pcre2_jit_stack variable to check pcre2_match_context instead. The former was already checked in the preceding "if" statement. This is a trivial and obvious error introduced in my commit 94da919 ("grep: add support for PCRE v2", 2017-06-01). In practice if pcre2_match_context_create() returned NULL we were likely in a situation where malloc() was returning NULL, and were thus screwed anyway, but if only the pcre2_match_context_create() call returned NULL (through some transitory bug) PCRE v2 would just allocate and supply its own context object when matching, and we'd run normally at the trivial expense of not getting a slight speedup by sharing the context object between successive matches. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94da919 commit 674ad93

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt
508508
if (!p->pcre2_jit_stack)
509509
die("Couldn't allocate PCRE2 JIT stack");
510510
p->pcre2_match_context = pcre2_match_context_create(NULL);
511-
if (!p->pcre2_jit_stack)
511+
if (!p->pcre2_match_context)
512512
die("Couldn't allocate PCRE2 match context");
513513
pcre2_jit_stack_assign(p->pcre2_match_context, NULL, p->pcre2_jit_stack);
514514
} else if (p->pcre2_jit_on != 0) {

0 commit comments

Comments
 (0)