Commit baef4d750d80fcf0fddce409470150e73ae120d3

Stefan Sperling 2022-05-18T07:44:49

plug memory leak in an error path of got_privsep_recv_tree()

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/lib/privsep.c b/lib/privsep.c
index 81911e2..7722c18 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -1630,6 +1630,8 @@ got_privsep_recv_tree(struct got_tree_object **tree, struct imsgbuf *ibuf)
 			    sizeof(struct got_tree_entry));
 			if ((*tree)->entries == NULL) {
 				err = got_error_from_errno("malloc");
+				free(*tree);
+				*tree = NULL;
 				break;
 			}
 			(*tree)->nentries = itree->nentries;