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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
149c83e0aa
commit
ee087c29c8
@ -1133,6 +1133,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||
&oid, &oc)) {
|
||||
if (seen_dashdash)
|
||||
die(_("unable to resolve revision: %s"), arg);
|
||||
object_context_release(&oc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
test_description='test case exclude pathspec'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='test labels in pathspecs'
|
||||
|
||||
TEST_PASSES_SANITIZE_LEAK=true
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'setup a tree' '
|
||||
|
||||
Reference in New Issue
Block a user