1
0
mirror of https://github.com/git/git.git synced 2024-09-16 21:01:42 +02:00

object-file: fix leak on conversion failure

I'm not sure exactly how to trigger the leak, but it seems fairly
obvious that the `content' buffer should be freed even if
convert_object_file() fails.  Noticed while working in this area
on unrelated things.

Signed-off-by: Eric Wong <e@80x24.org>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Wong 2024-06-22 04:36:48 +00:00 committed by Junio C Hamano
parent 786a3e4b8d
commit 493fdae046

View File

@ -1711,9 +1711,9 @@ static int oid_object_info_convert(struct repository *r,
ret = convert_object_file(&outbuf,
the_hash_algo, input_algo,
content, size, type, !do_die);
free(content);
if (ret == -1)
return -1;
free(content);
size = outbuf.len;
content = strbuf_detach(&outbuf, NULL);
}