commit 7d59fa89f063a4759446904a9601ee1374e9cad4 from: Stefan Sperling date: Sat Dec 28 13:48:41 2024 UTC make got-index-pack clear its imsgbuf on exit to avoid leak reports commit - 55e5ee714541266b7ee578082a5e0206c566f289 commit + 7d59fa89f063a4759446904a9601ee1374e9cad4 blob - 30b538316b641b0ebb47883992192f2d69452e31 blob + a7874929ef2212315a6a557833d30b138c854452 --- libexec/got-index-pack/got-index-pack.c +++ libexec/got-index-pack/got-index-pack.c @@ -102,22 +102,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; } #endif @@ -222,8 +223,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); }