Skip to content

Commit 85333aa

Browse files
peffgitster
authored andcommitted
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 7673ecd (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 6cd8369 (t/lib-gpg: call prepare_gnupghome() in GPG2 prereq, 2024-07-03). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a1cf0cf commit 85333aa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

t/helper/test-delete-gpgsig.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ int cmd__delete_gpgsig(int argc, const char **argv)
2323
if (!strcmp(pattern, "trailer")) {
2424
size_t payload_size = parse_signed_buffer(buf.buf, buf.len);
2525
fwrite(buf.buf, 1, payload_size, stdout);
26-
fflush(stdout);
27-
return 0;
26+
goto out;
2827
}
2928

3029
bufptr = buf.buf;
@@ -56,7 +55,9 @@ int cmd__delete_gpgsig(int argc, const char **argv)
5655
fwrite(bufptr, 1, (eol - bufptr) + 1, stdout);
5756
bufptr = eol + 1;
5857
}
59-
fflush(stdout);
6058

59+
out:
60+
fflush(stdout);
61+
strbuf_release(&buf);
6162
return 0;
6263
}

0 commit comments

Comments
 (0)