From: Junio C Hamano Date: Wed, 29 Oct 2025 19:35:17 GMT Subject: Re: [PATCH] test-tool: fix leak in delete-gpgsig command Message-ID: In-Reply-To: <20251029191031.GA1257596@coredump.intra.peff.net> Jeff King writes: > 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. >> cf. >> 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: Thanks. I was just looking at these failures and thanks for beating me to it. > -- >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 > --- > 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; > }