commit - 3ab5e33ce18309779415bf4e5e2464cbf01b06ac
commit + 2decf4c6adde2e9a8078b8af60c575c5bb91902a
blob - 75a81b01b8a5d3d012375c8636e429982efe65c1
blob + d093fd10dca947cf39e062dd85b6888dcb7ae8eb
--- lib/inflate.c
+++ lib/inflate.c
void *newbuf;
int nbuf = 1;
- *outbuf = malloc(GOT_INFLATE_BUFSIZE);
- if (*outbuf == NULL)
- return got_error_from_errno("malloc");
- err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
+ if (outbuf) {
+ *outbuf = malloc(GOT_INFLATE_BUFSIZE);
+ if (*outbuf == NULL)
+ return got_error_from_errno("malloc");
+ err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
+ } else
+ err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
if (err)
return err;
if (consumed_total)
*consumed_total += consumed;
if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
+ zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
+ if (outbuf == NULL)
+ continue;
newbuf = reallocarray(*outbuf, ++nbuf,
GOT_INFLATE_BUFSIZE);
if (newbuf == NULL) {
}
*outbuf = newbuf;
zb.outbuf = newbuf + *outlen;
- zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
}
} while (zb.flags & GOT_INFLATE_F_HAVE_MORE);
void *newbuf;
int nbuf = 1;
- *outbuf = malloc(GOT_INFLATE_BUFSIZE);
- if (*outbuf == NULL)
- return got_error_from_errno("malloc");
- err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
+ if (outbuf) {
+ *outbuf = malloc(GOT_INFLATE_BUFSIZE);
+ if (*outbuf == NULL)
+ return got_error_from_errno("malloc");
+ err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
+ } else
+ err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE);
if (err)
goto done;
if (consumed_total)
*consumed_total += consumed;
if (zb.flags & GOT_INFLATE_F_HAVE_MORE) {
+ zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
+ if (outbuf == NULL)
+ continue;
newbuf = reallocarray(*outbuf, ++nbuf,
GOT_INFLATE_BUFSIZE);
if (newbuf == NULL) {
}
*outbuf = newbuf;
zb.outbuf = newbuf + *outlen;
- zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
}
} while (zb.flags & GOT_INFLATE_F_HAVE_MORE);