commit - 666b4ca8b6176a8c10c13952d1176ad8974c6c57
commit + 17d745b8721ea2b811c9876638c588496f56d269
blob - cacf5c9f7f1b49a0c9305af7eba8aecf8b576294
blob + 8d7a9afa256fea6f0cca689baee19fce6680df6e
--- lib/inflate.c
+++ lib/inflate.c
size_t avail;
struct got_zstream_buf zb;
void *newbuf;
+ int nbuf = 1;
*outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE);
if (*outbuf == NULL)
goto done;
*outlen += avail;
if (zb.flags & GOT_ZSTREAM_F_HAVE_MORE) {
- newbuf = reallocarray(*outbuf, 1,
- *outlen + GOT_ZSTREAM_BUFSIZE);
+ nbuf++;
+ newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
+ GOT_ZSTREAM_BUFSIZE);
if (newbuf == NULL) {
err = got_error_from_errno();
free(*outbuf);
}
*outbuf = newbuf;
zb.outbuf = newbuf + *outlen;
- zb.outlen = GOT_ZSTREAM_BUFSIZE;
+ zb.outlen = (nbuf * GOT_ZSTREAM_BUFSIZE) - *outlen;
}
} while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE);
size_t avail;
struct got_zstream_buf zb;
void *newbuf;
+ int nbuf = 1;
*outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE);
if (*outbuf == NULL)
goto done;
*outlen += avail;
if (zb.flags & GOT_ZSTREAM_F_HAVE_MORE) {
- newbuf = reallocarray(*outbuf, 1,
- *outlen + GOT_ZSTREAM_BUFSIZE);
+ nbuf++;
+ newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
+ GOT_ZSTREAM_BUFSIZE);
if (newbuf == NULL) {
err = got_error_from_errno();
free(*outbuf);
}
*outbuf = newbuf;
zb.outbuf = newbuf + *outlen;
- zb.outlen = GOT_ZSTREAM_BUFSIZE;
+ zb.outlen = (nbuf * GOT_ZSTREAM_BUFSIZE) - *outlen;
}
} while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE);