[PATCH] test-tool: fix leak in delete-gpgsig command
- From
Jeff King <peff@peff.net>
- Date
- Oct 29, 2025, 19:10 UTC
- Message-ID
- <20251029191031.GA1257596@coredump.intra.peff.net>
- In-Reply-To
- <xmqqh5vibpqg.fsf@gitster.g>
On Tue, Oct 28, 2025 at 03:55:51PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> * 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. <ZoV8b2RvYxLOotSJ@teonanacatl.net> > cf. <xmqqbjlump3m.fsf@gitster.g> > cf. <87frb310d2.fsf_-_@email.froward.int.ebiederm.org> > source: <20240703153738.916469-1-tmz@pobox.com>
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 <peff@peff.net> --- 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