]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: clear oidset after finishing write
authorJeff King <peff@peff.net>
Tue, 3 Oct 2023 20:31:30 +0000 (16:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Oct 2023 21:28:24 +0000 (14:28 -0700)
In graph_write() we store commits in an oidset, but never clean it up,
leaking the contents. We should clear it in the cleanup section.

The oidset comes from 6830c36077 (commit-graph.h: replace 'commit_hex'
with 'commits', 2020-04-13), but it was just replacing a string_list
that was also leaked. Curiously, we fixed the leak of some adjacent
variables in commit fa8953cb40 (builtin/commit-graph.c: extract
'read_one_commit()', 2020-05-18), but the oidset wasn't included for
some reason.

In combination with the preceding commits, this lets us mark t5324 as
leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit-graph.c
t/t5324-split-commit-graph.sh

index c88389df24ed5cb552ca22a4be0e29c625a9ac23..c527a8369e35d64fa99be2e70c6db572d8af78cb 100644 (file)
@@ -311,6 +311,7 @@ cleanup:
        FREE_AND_NULL(options);
        string_list_clear(&pack_indexes, 0);
        strbuf_release(&buf);
+       oidset_clear(&commits);
        return result;
 }
 
index 36c4141e67b8f0f5aaf87443ab0c00f2bbd67836..52e8a3e6199f4015731d624df457babfcc5e3749 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='split commit graph'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 GIT_TEST_COMMIT_GRAPH=0