commit 06b34d6ebec64e3072376c878d5b9c7c488ab805d30cb02330975fcaec56bfb5 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 - 91357e056c69195f7763063d4cec6ecefdfef7ab3aeb4cd15b597701f5fcbb6f commit + 06b34d6ebec64e3072376c878d5b9c7c488ab805d30cb02330975fcaec56bfb5 blob - ed58db52c4ace8e9fd6dc31bccffed40c76cdf8de70cae6baab54b476a9cce82 blob + 9747397a896f98857369d81ecadf8fb669c22ea8bcd96fbf5b822d6e1364c8af --- 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); }