Commit Diff


commit - d1078c40c0a28790e906d27e22df90d0337e6002
commit + f2c5fe0e01b265dfe66dfa19e99e5a30cd738363
blob - 164e5b27b1b1c9133603848641044f7a34398cd6
blob + 524f0c332e9c351c4102011bce7c44cb71b9576a
--- lib/inflate.c
+++ lib/inflate.c
@@ -262,7 +262,7 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen
 	void *newbuf;
 	int nbuf = 1;
 
-	*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
+	*outbuf = malloc(GOT_INFLATE_BUFSIZE);
 	if (*outbuf == NULL)
 		return got_error_from_errno("calloc");
 	err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
@@ -277,11 +277,10 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen
 			goto done;
 		*outlen += avail;
 		if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
-			nbuf++;
-			newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
+			newbuf = reallocarray(*outbuf, ++nbuf,
 			    GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {
-				err = got_error_from_errno("recallocarray");
+				err = got_error_from_errno("reallocarray");
 				free(*outbuf);
 				*outbuf = NULL;
 				*outlen = 0;