Skip to content

Commit ee087c2

Browse files
pks-tgitster
authored andcommitted
builtin/grep: fix leaking object context
Even when `get_oid_with_context()` fails it may have allocated some data in the object context. But we do not release it in git-grep(1) when the call fails, leading to a memory leak. Plug it. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 149c83e commit ee087c2

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

builtin/grep.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
11331133
&oid, &oc)) {
11341134
if (seen_dashdash)
11351135
die(_("unable to resolve revision: %s"), arg);
1136+
object_context_release(&oc);
11361137
break;
11371138
}
11381139

t/t6132-pathspec-exclude.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='test case exclude pathspec'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success 'setup' '

t/t6135-pathspec-with-attrs.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test labels in pathspecs'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup a tree' '

0 commit comments

Comments
 (0)