Commit 6336b73f5e18e9020c14f6eed1b543ab7d098381

Stefan Sperling 2018-01-27T03:03:21

Fix output length if got_inflate_read() reads some data and then EOF.

diff --git a/lib/zb.c b/lib/zb.c
index fa57ae6..361d6bd 100644
--- a/lib/zb.c
+++ b/lib/zb.c
@@ -73,6 +73,7 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *inlenp,
 	z->next_out = zb->outbuf;
 	z->avail_out = zb->outlen;
 
+	*outlenp = 0;
 	if (inlenp)
 		*inlenp = 0;
 	do {
@@ -81,8 +82,7 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *inlenp,
 			if (n == 0) {
 				if (ferror(f))
 					return got_ferror(f, GOT_ERR_IO);
-				*outlenp = 0;
-				return NULL;
+				break; /* EOF */
 			}
 			z->next_in = zb->inbuf;
 			z->avail_in = n;