]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: stop leaking buffer in http_get_info_packs()
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 22:02:27 +0000 (18:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:55 +0000 (10:24 -0700)
We use http_get_strbuf() to fetch the remote info/packs content into a
strbuf, but never free it, causing a leak. There's no need to hold onto
it, as we've already parsed it completely.

This lets us mark t5619 as leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c
t/t5619-clone-local-ambiguous-transport.sh

diff --git a/http.c b/http.c
index 4d841becca5baa10d1c0270449905783f23b2d37..54463770b4d06b93e33bdab637b83d801473161a 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2475,6 +2475,7 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)
 
 cleanup:
        free(url);
+       strbuf_release(&buf);
        return ret;
 }
 
index cce62bf78d335134903b996c7363c4230ae5ded3..1d4efe414daac1f52b7ed2ad1d5b94e6fb3514dd 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='test local clone with ambiguous transport'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY/lib-httpd.sh"