git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] object-file: fix leak on conversion failure
@ 2024-06-22  4:36 Eric Wong
  2024-06-23 16:34 ` Derrick Stolee
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2024-06-22  4:36 UTC (permalink / raw)
  To: Eric W. Biederman, git

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>
---
 object-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/object-file.c b/object-file.c
index d3cf4b8b2e..00c8f1039b 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);
 		}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-24 16:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-22  4:36 [PATCH] object-file: fix leak on conversion failure Eric Wong
2024-06-23 16:34 ` Derrick Stolee
2024-06-24 16:08   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).