From: Patrick Steinhardt Date: Tue, 5 Nov 2024 06:16:50 +0000 (+0100) Subject: grep: fix leak in `grep_splice_or()` X-Git-Tag: v2.48.0-rc0~65^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6590ccdd431e2ab7b9c521cac674546725a54d2;p=thirdparty%2Fgit.git grep: fix leak in `grep_splice_or()` 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 Signed-off-by: Junio C Hamano --- diff --git a/grep.c b/grep.c index 701e58de04..e9337f32cb 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; }