Commit fca1f6ad74d7a0a330d6014cdecbe6099bfc152e

Stefan Sperling 2020-08-27T10:05:38

plug a memory leak in got_privsep_recv_tree() in error case found while looking over tracey's scan-build results

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/privsep.c b/lib/privsep.c
index 79edb65..bc39682 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -1199,8 +1199,11 @@ get_more:
 			break;
 		}
 
-		if (imsg.hdr.len < IMSG_HEADER_SIZE + min_datalen)
-			return got_error(GOT_ERR_PRIVSEP_LEN);
+		if (imsg.hdr.len < IMSG_HEADER_SIZE + min_datalen) {
+			imsg_free(&imsg);
+			err = got_error(GOT_ERR_PRIVSEP_LEN);
+			break;
+		}
 
 		datalen = imsg.hdr.len - IMSG_HEADER_SIZE;