Commit Diff


commit - 7f358e3b0ea7c7873900dbce1501c56711d7275d
commit + 3b6470856ee51fa2c923b54719c254b5dedde8e8
blob - 8d611b1a6422d66a82e9e74240412c54d608896f
blob + 72b117bda7b580c8148fc198ffdf9d09d95fc927
--- lib/privsep.c
+++ lib/privsep.c
@@ -734,19 +734,22 @@ got_privsep_send_tree(struct imsgbuf *ibuf, struct got
 			return got_error_from_errno("imsg_create TREE_ENTRY");
 
 		/* Keep in sync with struct got_imsg_tree_object definition! */
-		if (imsg_add(wbuf, pte->id, SHA1_DIGEST_LENGTH) == -1)
+		if (imsg_add(wbuf, pte->id, SHA1_DIGEST_LENGTH) == -1) {
 			err = got_error_from_errno("imsg_add TREE_ENTRY");
-		if (err)
+			ibuf_free(wbuf);
 			return err;
-		if (imsg_add(wbuf, &pte->mode, sizeof(pte->mode)) == -1)
+		}
+		if (imsg_add(wbuf, &pte->mode, sizeof(pte->mode)) == -1) {
 			err = got_error_from_errno("imsg_add TREE_ENTRY");
-		if (err)
+			ibuf_free(wbuf);
 			return err;
+		}
 
-		if (imsg_add(wbuf, name, namelen) == -1)
+		if (imsg_add(wbuf, name, namelen) == -1) {
 			err = got_error_from_errno("imsg_add TREE_ENTRY");
-		if (err)
+			ibuf_free(wbuf);
 			return err;
+		}
 
 		wbuf->fd = -1;
 		imsg_close(ibuf, wbuf);