From: Eric Wong Date: Sat, 22 Jun 2024 04:36:48 +0000 (+0000) Subject: object-file: fix leak on conversion failure X-Git-Tag: v2.46.0-rc0~16^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=493fdae0464282fbac99f60d94bfaabf5559c9ff;p=thirdparty%2Fgit.git 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 Acked-by: Derrick Stolee Signed-off-by: Junio C Hamano --- diff --git a/object-file.c b/object-file.c index 610b1f465c..dd441627d6 100644 --- a/object-file.c +++ b/object-file.c @@ -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); }