From c122da9b86f71e517f2ea57b9d828e83e188c764 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Sat, 28 Dec 2024 13:48:41 +0000 Subject: [PATCH] make got-index-pack clear its imsgbuf on exit to avoid leak reports --- libexec/got-index-pack/got-index-pack.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c index ae7314d0..2df5821a 100644 --- a/libexec/got-index-pack/got-index-pack.c +++ b/libexec/got-index-pack/got-index-pack.c @@ -101,22 +101,23 @@ main(int argc, char **argv) for (i = 0; i < nitems(tmpfiles); i++) tmpfiles[i] = NULL; - memset(&pack, 0, sizeof(pack)); - pack.fd = -1; - err = got_delta_cache_alloc(&pack.delta_cache); - if (err) - goto done; - if (imsgbuf_init(&ibuf, GOT_IMSG_FD_CHILD) == -1) { warn("imsgbuf_init"); return 1; } imsgbuf_allow_fdpass(&ibuf); + + memset(&pack, 0, sizeof(pack)); + pack.fd = -1; + err = got_delta_cache_alloc(&pack.delta_cache); + if (err) + goto done; #ifndef PROFILE /* revoke access to most system calls */ if (pledge("stdio recvfd", NULL) == -1) { err = got_error_from_errno("pledge"); got_privsep_send_error(&ibuf, err); + imsgbuf_clear(&ibuf); return 1; } @@ -233,8 +234,10 @@ done: got_privsep_send_error(&ibuf, err); fprintf(stderr, "%s: %s\n", getprogname(), err->msg); got_privsep_send_error(&ibuf, err); + imsgbuf_clear(&ibuf); exit(1); } + imsgbuf_clear(&ibuf); exit(0); } -- 2.11.4.GIT