commit c3ff86b21e8e12f5af1145b9e6fe2aa5b735a141 from: Stefan Sperling date: Sat Dec 28 14:32:19 2024 UTC do not leak privsep_child memory allocations if sending a stop command fails commit - b642df222fe314b84ca87cefd3f086907f35df5c commit + c3ff86b21e8e12f5af1145b9e6fe2aa5b735a141 blob - 0258f1df3dcad137a19421f6c9b65c513b5b6efe blob + 0208d34446408dede8a64218a54434810ff24a14 --- lib/pack.c +++ lib/pack.c @@ -814,19 +814,20 @@ done: static const struct got_error * pack_stop_privsep_child(struct got_pack *pack) { - const struct got_error *err = NULL, *close_err = NULL; + const struct got_error *err = NULL; + const struct got_error *close_err = NULL, *child_err = NULL; if (pack->privsep_child == NULL) return NULL; err = got_privsep_send_stop(pack->privsep_child->imsg_fd); - if (err) - return err; if (close(pack->privsep_child->imsg_fd) == -1) close_err = got_error_from_errno("close"); - err = got_privsep_wait_for_child(pack->privsep_child->pid); if (close_err && err == NULL) err = close_err; + child_err = got_privsep_wait_for_child(pack->privsep_child->pid); + if (child_err && err == NULL) + err = child_err; imsgbuf_clear(pack->privsep_child->ibuf); free(pack->privsep_child->ibuf); free(pack->privsep_child);