]> git.ipfire.org Git - thirdparty/git.git/commit
http-push: clean up local_refs at exit
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 22:12:39 +0000 (18:12 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:58 +0000 (10:24 -0700)
commitf4c768c639566da07fc063fa9b52607f54ac94ee
treee810a7d370b429b04bf558567fa7d1a230ae7ae1
parent9699327945d16f67f8a20a299d63621a3b1d3cd2
http-push: clean up local_refs at exit

We allocate a list of ref structs from get_local_heads() but never clean
it up. We should do so before exiting to avoid complaints from the
leak-checker. Note that we have to initialize it to NULL, because
there's one code path that can jump to the cleanup label before we
assign to it.

Fixing this lets us mark t5540 as leak-free.

Curiously building with SANITIZE=leak and gcc does not seem to find this
problem, but switching to clang does. It seems like a fairly obvious
leak, though.

I was curious that the matching remote_refs did not have the same leak.
But that is because we store the list in a global variable, so it's
still reachable after we exit. Arguably we could treat it the same as
future-proofing, but I didn't bother (now that the script is marked
leak-free, anybody moving it to a stack variable will notice).

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