commit c122da9b86f71e517f2ea57b9d828e83e188c764 from: Stefan Sperling via: Thomas Adam date: Fri Jan 03 10:46:48 2025 UTC make got-index-pack clear its imsgbuf on exit to avoid leak reports commit - 1062a61bb848c75e2c75d6145c3cf643d314c493 commit + c122da9b86f71e517f2ea57b9d828e83e188c764 blob - ae7314d07929ec90ae1c9e9a8f74aea2e344bddb blob + 2df5821acb36e16307473ce40fae65e904a9d9de --- libexec/got-index-pack/got-index-pack.c +++ 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); }