]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http-push: clean up loose request when falling back to packed
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 22:11:13 +0000 (18:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:58 +0000 (10:24 -0700)
In http-push's finish_request(), if we fail a loose object request we
may fall back to trying a packed request. But if we do so, we leave the
http_loose_object_request in place, leaking it.

We can fix this by always cleaning it up. Note that the obj_req pointer
here (which we'll set to NULL) is a copy of the request->userData
pointer, which will now point to freed memory. But that's OK. We'll
either release the parent request struct entirely, or we'll convert it
into a packed request, which will overwrite userData itself.

This leak is found by t5540, but it's not quite leak-free yet.

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

index 1cddd2fb37e2094754b2568aa9461150acd6c4f2..b36b1f9e35bc6ac6885881dcd1205ea2c6e494bd 100644 (file)
@@ -582,9 +582,10 @@ static void finish_request(struct transfer_request *request)
                        if (obj_req->rename == 0)
                                request->obj->flags |= (LOCAL | REMOTE);
 
+               release_http_object_request(&obj_req);
+
                /* Try fetching packed if necessary */
                if (request->obj->flags & LOCAL) {
-                       release_http_object_request(&obj_req);
                        release_request(request);
                } else
                        start_fetch_packed(request);