Thread (3 messages) 3 messages, 3 authors, 2025-10-30
STALE237d

[PATCH] test-tool: fix leak in delete-gpgsig command

From: Jeff King <hidden>
Date: 2025-10-29 19:10:32
Subsystem: the rest · Maintainer: Linus Torvalds

On Tue, Oct 28, 2025 at 03:55:51PM -0700, Junio C Hamano wrote:
* tz/test-prepare-gnupghome (2024-07-03) 2 commits
 - t/lib-gpg: call prepare_gnupghome() in GPG2 prereq
 - t/lib-gpg: add prepare_gnupghome() to create GNUPGHOME dir

 Tests did not set up GNUPGHOME correctly, which is fixed but some
 flaky tests are exposed in t1016, which needs to be addressed
 before this topic can move forward.

 Will merge to 'next'.
 cf. [ref]
 cf. <xmqqbjlump3m.fsf@gitster.g>
 cf. [ref]
 source: [ref]
I noticed jch failing CI. I think we want this on top:

-- >8 --
Subject: [PATCH] test-tool: fix leak in delete-gpgsig command

We read the input into a strbuf, so we must free it. Without this, t1016
complains in SANITIZE=leak mode.

The bug was introduced in 7673ecd2dc (t1016-compatObjectFormat: add
tests to verify the conversion between objects, 2023-10-01). But nobody
seems to have noticed, probably because CI did not run these tests until
the fix in 6cd8369ef3 (t/lib-gpg: call prepare_gnupghome() in GPG2
prereq, 2024-07-03).

Signed-off-by: Jeff King <redacted>
---
 t/helper/test-delete-gpgsig.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/t/helper/test-delete-gpgsig.c b/t/helper/test-delete-gpgsig.c
index e36831af03..658c7a37f7 100644
--- a/t/helper/test-delete-gpgsig.c
+++ b/t/helper/test-delete-gpgsig.c
@@ -23,8 +23,7 @@ int cmd__delete_gpgsig(int argc, const char **argv)
 	if (!strcmp(pattern, "trailer")) {
 		size_t payload_size = parse_signed_buffer(buf.buf, buf.len);
 		fwrite(buf.buf, 1, payload_size, stdout);
-		fflush(stdout);
-		return 0;
+		goto out;
 	}
 
 	bufptr = buf.buf;
@@ -56,7 +55,9 @@ int cmd__delete_gpgsig(int argc, const char **argv)
 		fwrite(bufptr, 1, (eol - bufptr) + 1, stdout);
 		bufptr = eol + 1;
 	}
-	fflush(stdout);
 
+out:
+	fflush(stdout);
+	strbuf_release(&buf);
 	return 0;
 }
-- 
2.51.2.833.g5cd7b514cb
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help