commit 6dc3b75a27a79e74c8221bd260f619fe58ca4619 from: Stefan Sperling date: Wed May 22 10:54:14 2019 UTC no need to zero memory in got_inflate_to_mem() commit - b48e2ddb7c7f3bec51c4be31a1484677022384e8 commit + 6dc3b75a27a79e74c8221bd260f619fe58ca4619 blob - cf569abc9136ea5fefdadf1a9a9fde8eaf66ab66 blob + 164e5b27b1b1c9133603848641044f7a34398cd6 --- lib/inflate.c +++ lib/inflate.c @@ -218,7 +218,7 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, 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, 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;