Commit e302c59e513bd3808c6c02c3b3237ba3d0267114

Stefan Sperling 2017-12-02T00:44:09

check recallocarray return value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/lib/object.c b/lib/object.c
index 5274de4..f9e0057 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -229,8 +229,13 @@ read_object_header(struct got_object **obj, struct got_repository *repo,
 		err = inflate_read(&zb, f, &outlen);
 		if (err)
 			goto done;
-		if (strchr(zb.outbuf, '\0') == NULL)
+		if (strchr(zb.outbuf, '\0') == NULL) {
 			buf = recallocarray(buf, 1 + i, 2 + i, zbsize);
+			if (buf == NULL) {
+				err = got_error(GOT_ERR_NO_MEM);
+				goto done;
+			}
+		}
 		memcpy(buf, zb.outbuf, outlen);
 		totlen += outlen;
 		i++;