From: Patrick Steinhardt Date: Tue, 5 Nov 2024 06:17:26 +0000 (+0100) Subject: builtin/tag: fix leaking key ID on failure to sign X-Git-Tag: v2.48.0-rc0~65^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d06e3ec858d4863baa5f918db414e890b08891d7;p=thirdparty%2Fgit.git builtin/tag: fix leaking key ID on failure to sign We do not free the key ID when signing a tag fails. Do so by using the common exit path. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/builtin/tag.c b/builtin/tag.c index 93d10d5915..c37c0a68fd 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -164,7 +164,7 @@ static int do_sign(struct strbuf *buffer, struct object_id **compat_oid, int ret = -1; if (sign_buffer(buffer, &sig, keyid)) - return -1; + goto out; if (compat) { const struct git_hash_algo *algo = the_repository->hash_algo; diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index b1316e62f4..42b3327e69 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -10,6 +10,7 @@ Tests for operations with tags.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-terminal.sh