Skip to content

Commit a6590cc

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee3e8c3 commit a6590cc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

grep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ static struct grep_expr *grep_splice_or(struct grep_expr *x, struct grep_expr *y
756756
assert(x->node == GREP_NODE_OR);
757757
if (x->u.binary.right &&
758758
x->u.binary.right->node == GREP_NODE_TRUE) {
759+
free(x->u.binary.right);
759760
x->u.binary.right = y;
760761
break;
761762
}

0 commit comments

Comments
 (0)