]> git.ipfire.org Git - thirdparty/git.git/commit
http-push: free transfer_request strbuf
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 22:08:49 +0000 (18:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:57 +0000 (10:24 -0700)
commit94c62857808bdd6b5b061284eb9dfd13204bd11a
treeac11539cc2193274a7cf590ce7e8997bce8a5b1e
parent7d3c71ddbf346bb5182d1cbb4610b9b575b34491
http-push: free transfer_request strbuf

When we issue a PUT, we initialize and fill a strbuf embedded in the
transfer_request struct. But we never release this buffer, causing a
leak.

We can fix this by adding a strbuf_release() call to release_request().
If we stopped there, then non-PUT requests would try to release a
zero-initialized strbuf. This works OK in practice, but we should try to
follow the strbuf API more closely. So instead, we'll always initialize
the strbuf when we create the transfer_request struct.

That in turn means switching the strbuf_init() call in start_put() to a
simple strbuf_grow().

This leak is triggered in t5540.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-push.c