Commit Diff


commit - 1e87a3c39e7647b4dba91b8b1c77da25d677294a
commit + 5eddcd6036f58003c938979c222ae67c455f38df
blob - 75d3b40de1a47788c753781ed4e70deaaf8ef0f1
blob + adb65f7160aeb80a3a64d7178286e66c5c9815e5
--- lib/inflate.c
+++ lib/inflate.c
@@ -287,9 +287,9 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen,
 		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;
+			zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
 			newbuf = reallocarray(*outbuf, ++nbuf,
 			   GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {
@@ -343,9 +343,9 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen
 		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;
+			zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen;
 			newbuf = reallocarray(*outbuf, ++nbuf,
 			    GOT_INFLATE_BUFSIZE);
 			if (newbuf == NULL) {