]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/describe: fix trivial memory leak when describing blob
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2024 10:38:30 +0000 (12:38 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2024 15:47:35 +0000 (08:47 -0700)
We never free the `struct strvec args` variable in `describe_blob()`,
which thus causes a memory leak. Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
t/t9903-bash-prompt.sh

index 2957ff70315d098d159fc89ad57bb645edbf03e0..954929c5142b7f6309cb70f25c8e1100f33ed023 100644 (file)
@@ -529,6 +529,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
        traverse_commit_list(&revs, process_commit, process_object, &pcd);
        reset_revision_walk();
        release_revisions(&revs);
+       strvec_clear(&args);
 }
 
 static void describe(const char *arg, int last_one)
index d667dda654e2de7f32d5f7d065f6eac59ca9fdbf..95e9955bca1bed2f5f51127d1793ac71bebb23c5 100755 (executable)
@@ -8,6 +8,7 @@ test_description='test git-specific bash prompt functions'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./lib-bash.sh
 
 . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"