[PATCH v3 03/22] grep: fix leak in `grep_splice_or()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 5, 2024, 06:16 UTC
- Message-ID
- <74b214701942b6412965b53b3aec4580ef6fd242.1730786196.git.ps@pks.im>
- In-Reply-To
- <cover.1730786195.git.ps@pks.im>
In `grep_splice_or()` we search for the next `TRUE` node in our tree of grep expressions and replace it with the given new expression. But we don't free the old node, which causes a memory leak. Plug it.
This leak is exposed by t7810, but plugging it alone isn't sufficient to make the test suite pass.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- grep.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/grep.c b/grep.c index 701e58de04e..e9337f32cbf 100644 --- a/grep.c +++ b/grep.c @@ -756,6 +756,7 @@ static struct grep_expr *grep_splice_or(struct grep_expr *x, struct grep_expr *y assert(x->node == GREP_NODE_OR); if (x->u.binary.right && x->u.binary.right->node == GREP_NODE_TRUE) { + free(x->u.binary.right); x->u.binary.right = y; break; }
-- 2.47.0.229.g8f8d6eee53.dirty