commit e2308af98f7d01e81f6173b9c264b1c21190a24a from: Kyle Ackerman via: Omar Polo date: Tue Oct 01 07:39:01 2024 UTC plug a memory leak in got_privsep_recv_send_remote_ref We didn't always call imsg_free(); while here also fix the `default` branch so it actually errors on unexpected messages. Diff from Kyle Ackerman with tweaks from tb@ commit - 5c584cf5785c945cd2a86cd9202f672801edec1e commit + e2308af98f7d01e81f6173b9c264b1c21190a24a blob - 116131bdf6703cf5fe030ee142ac6ffed00267b4 blob + 25f3858f09dbd0bc936d97fc851892955ecf6623 --- lib/privsep.c +++ lib/privsep.c @@ -941,13 +941,12 @@ got_privsep_recv_send_remote_refs(struct got_pathlist_ const struct got_error *err = NULL; struct imsg imsg; size_t datalen; - int done = 0; struct got_imsg_send_remote_ref iremote_ref; struct got_object_id *id = NULL; char *refname = NULL; struct got_pathlist_entry *new; - while (!done) { + while (1) { err = got_privsep_recv_imsg(&imsg, ibuf, 0); if (err) return err; @@ -986,6 +985,7 @@ got_privsep_recv_send_remote_refs(struct got_pathlist_ } id = NULL; refname = NULL; + imsg_free(&imsg); break; case GOT_IMSG_SEND_PACK_REQUEST: if (datalen != 0) { @@ -993,11 +993,10 @@ got_privsep_recv_send_remote_refs(struct got_pathlist_ goto done; } /* got-send-pack is now waiting for a pack file. */ - done = 1; - break; + goto done; default: err = got_error(GOT_ERR_PRIVSEP_MSG); - break; + goto done; } } done: