Commit b3a605cef0134962ad1a3bb6f54db3c29aae3fdc

Stefan Sperling 2019-05-22T12:58:40

no need to zero memory in got_inflate_to_mem_mmap()

diff --git a/lib/inflate.c b/lib/inflate.c
index 524f0c3..d393031 100644
--- a/lib/inflate.c
+++ b/lib/inflate.c
@@ -307,7 +307,7 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outlen, uint8_t *map,
 	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);
@@ -330,11 +330,10 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outlen, uint8_t *map,
 		if (len == 0)
 			break;
 		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;