{"thread":{"id":"46215","subject":"[PATCH] grep: fix erroneously copy/pasted variable in check/assert pattern","startedAt":"2017-06-19T22:02:05Z","lastAt":"2017-06-19T22:02:05Z","messageCount":1,"participants":["Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"322623","messageId":"20170619220148.11199-1-avarab@gmail.com","threadId":"46215","inReplyTo":null,"subject":"[PATCH] grep: fix erroneously copy/pasted variable in check/assert pattern","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-06-19T22:01:48Z","receivedAt":"2017-06-19T22:02:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Fix an erroneously copy/pasted check for the pcre2_jit_stack variable\nto check pcre2_match_context instead. The former was already checked\nin the preceding \"if\" statement.\n\nThis is a trivial and obvious error introduced in my commit\n94da9193a6 (\"grep: add support for PCRE v2\", 2017-06-01).\n\nIn practice if pcre2_match_context_create() returned NULL we were\nlikely in a situation where malloc() was returning NULL, and were thus\nscrewed anyway, but if only the pcre2_match_context_create() call\nreturned NULL (through some transitory bug) PCRE v2 would just\nallocate and supply its own context object when matching, and we'd run\nnormally at the trivial expense of not getting a slight speedup by\nsharing the context object between successive matches.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/grep.c b/grep.c\nindex d7ef21358e..06c4c24926 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -508,7 +508,7 @@ static void compile_pcre2_pattern(struct grep_pat *p, const struct grep_opt *opt\n \t\tif (!p->pcre2_jit_stack)\n \t\t\tdie(\"Couldn't allocate PCRE2 JIT stack\");\n \t\tp->pcre2_match_context = pcre2_match_context_create(NULL);\n-\t\tif (!p->pcre2_jit_stack)\n+\t\tif (!p->pcre2_match_context)\n \t\t\tdie(\"Couldn't allocate PCRE2 match context\");\n \t\tpcre2_jit_stack_assign(p->pcre2_match_context, NULL, p->pcre2_jit_stack);\n \t} else if (p->pcre2_jit_on != 0) {\n-- \n2.13.1.518.g3df882009\n\n"}]}