From: Kyle Ackerman Subject: Re: got_blame memory leak To: gameoftrees@openbsd.org Date: Sun, 24 Mar 2024 18:48:05 -0500 Here is alternative diff. Rather than checking after every message received, we can just allocate the got_object_id once we receive a GOT_IMSG_COMMIT_TRAVERSAL_DONE. This is here in case checking to see if changed_commit_id is not null after each imsg is ugly.` diff /home/kyle/src/got commit - 39910b637a9a53cc48b0c63766da691dec0af593 path + /home/kyle/src/got blob - 857c09bbb3a5d9425176ed93727a912b2242aac6 file + lib/privsep.c --- lib/privsep.c +++ lib/privsep.c @@ -2730,8 +2730,7 @@ got_privsep_recv_traversed_commits(struct got_commit_o /* The last commit may contain a change. */ if (i == icommits->ncommits - 1) { - *changed_commit_id = - got_object_id_dup(&qid->id); + *changed_commit_id = &qid->id; if (*changed_commit_id == NULL) { err = got_error_from_errno( "got_object_id_dup"); @@ -2749,6 +2748,7 @@ got_privsep_recv_traversed_commits(struct got_commit_o datalen, ibuf); break; case GOT_IMSG_COMMIT_TRAVERSAL_DONE: + *changed_commit_id = got_object_id_dup(*changed_commit_id); done = 1; break; default: