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:
Patrick Steinhardt
2024-09-05 12:09:31 +02:00
committed by Junio C Hamano
parent 149c83e0aa
commit ee087c29c8
3 changed files with 4 additions and 0 deletions

View File

@ -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;
}