Commit b1317e77b872eb5ef148f76b5b63d358cc868a75

Stefan Sperling 2019-09-22T10:51:10

plug error leak in got_packidx_init_hdr(); found by jj@ with scan-build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/pack.c b/lib/pack.c
index fedfa0d..b39b112 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -95,9 +95,10 @@ got_packidx_init_hdr(struct got_packidx *p, int verify)
 			goto done;
 		}
 		n = read(p->fd, h->magic, sizeof(*h->magic));
-		if (n < 0)
+		if (n < 0) {
 			err = got_error_from_errno("read");
-		else if (n != sizeof(*h->magic)) {
+			goto done;
+		} else if (n != sizeof(*h->magic)) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
 		}