From ad6e5cbcf598f55cafe83a11487ea4a6694e433b Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 14 Nov 2021 10:54:12 -0800
Subject: [PATCH] grep: fix minor -P memory leak

* src/pcresearch.c (Pcompile): Free ccontext when no longer needed.
---
 src/pcresearch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pcresearch.c b/src/pcresearch.c
index badcd4c..c287d99 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -184,6 +184,8 @@ Pcompile (char *pattern, size_t size, reg_syntax_t ignored, bool exact)
       die (EXIT_TROUBLE, 0, "%s", ep);
     }
 
+  pcre2_compile_context_free (ccontext);
+
   pc->data = pcre2_match_data_create_from_pattern (pc->cre, NULL);
 
   ec = pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
-- 
1.8.3.1

