commit b3a605cef0134962ad1a3bb6f54db3c29aae3fdc from: Stefan Sperling date: Wed May 22 10:58:40 2019 UTC no need to zero memory in got_inflate_to_mem_mmap() commit - f2c5fe0e01b265dfe66dfa19e99e5a30cd738363 commit + b3a605cef0134962ad1a3bb6f54db3c29aae3fdc blob - 524f0c332e9c351c4102011bce7c44cb71b9576a blob + d393031f5f1064c32785a460c7f37e6c85673645 --- lib/inflate.c +++ lib/inflate.c @@ -307,7 +307,7 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl 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 *outl 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;