Commit 6dc3b75a27a79e74c8221bd260f619fe58ca4619

Stefan Sperling 2019-05-22T12:54:14

no need to zero memory in got_inflate_to_mem()

diff --git a/lib/inflate.c b/lib/inflate.c
index cf569ab..164e5b2 100644
--- a/lib/inflate.c
+++ b/lib/inflate.c
@@ -218,7 +218,7 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f)
 	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);
@@ -233,11 +233,10 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f)
 			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;