summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-11-14 09:39:05 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-11-14 12:13:28 -0800
commit99fcca954f4ec1ae1e9a86e8ce95d5f66091b871 (patch)
tree4b743aff7289d18ab5c43fb6147fc3b2508f56a0 /src
parenta0feba0a48de0d6f55c0feaa5353afdcf2b24474 (diff)
downloadgrep-99fcca954f4ec1ae1e9a86e8ce95d5f66091b871.tar.gz
grep: use ximalloc, not xcalloc
* src/pcresearch.c (Pcompile): Use ximalloc, not xcalloc, and explicitly initialize the two slots that should be null. This is more likely to catch future errors if we use valgrind.
Diffstat (limited to 'src')
-rw-r--r--src/pcresearch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c
index a99835e3..dea39f03 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -134,7 +134,7 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact)
int ec;
int flags = PCRE2_DOLLAR_ENDONLY | (match_icase ? PCRE2_CASELESS : 0);
char *patlim = pattern + size;
- struct pcre_comp *pc = xcalloc (1, sizeof (*pc));
+ struct pcre_comp *pc = ximalloc (sizeof *pc);
pcre2_general_context *gcontext = pc->gcontext
= pcre2_general_context_create (private_malloc, private_free, NULL);
pcre2_compile_context *ccontext = pcre2_compile_context_create (gcontext);
@@ -203,6 +203,7 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact)
free (re_storage);
+ pc->mcontext = NULL;
pc->data = pcre2_match_data_create_from_pattern (pc->cre, gcontext);
ec = pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
@@ -210,6 +211,7 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact)
die (EXIT_TROUBLE, 0, _("JIT internal error: %d"), ec);
/* The PCRE documentation says that a 32 KiB stack is the default. */
+ pc->jit_stack = NULL;
pc->jit_stack_size = 32 << 10;
pc->empty_match[false] = jit_exec (pc, "", 0, 0, PCRE2_NOTBOL);