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>
Eric Wong committed
Jun 22, 2024 at 04:36 UTC
493fdae0464282fbac99f60d94bfaabf5559c9ff
1 file changed
+1
-1
object-file.c
+1
-1
@@ -1711,9 +1711,9 @@ static int oid_object_info_convert(struct repository *r,
1711
ret = convert_object_file(&outbuf,
1712
the_hash_algo, input_algo,
1713
content, size, type, !do_die);
1714
+ free(content);
1715
if (ret == -1)
1716
return -1;
1716
- free(content);
1717
size = outbuf.len;
1718
content = strbuf_detach(&outbuf, NULL);
1719
}