diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2024-02-02 16:13:24 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2024-02-04 18:49:40 -0800 |
commit | bb054d95d0336f8d36c85c5f1d8a98f935a3c131 (patch) | |
tree | 6dcafef3f53a7985d131fd9b6cb3ce9084230426 /examples | |
parent | be4db0a79add326bf06ff46b550f564288749f90 (diff) | |
download | zlib-bb054d95d0336f8d36c85c5f1d8a98f935a3c131.tar.gz zlib-bb054d95d0336f8d36c85c5f1d8a98f935a3c131.tar.bz2 zlib-bb054d95d0336f8d36c85c5f1d8a98f935a3c131.zip |
Stop decoding in zran.c once request is satisfied.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/zran.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/zran.c b/examples/zran.c index 9c3e5dc..d3f5a36 100644 --- a/examples/zran.c +++ b/examples/zran.c | |||
@@ -402,8 +402,12 @@ ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, | |||
402 | // Update the appropriate count. | 402 | // Update the appropriate count. |
403 | if (offset) | 403 | if (offset) |
404 | offset -= got; | 404 | offset -= got; |
405 | else | 405 | else { |
406 | left -= got; | 406 | left -= got; |
407 | if (left == 0) | ||
408 | // Request satisfied. | ||
409 | break; | ||
410 | } | ||
407 | 411 | ||
408 | // If we're at the end of a gzip member and there's more to read, | 412 | // If we're at the end of a gzip member and there's more to read, |
409 | // continue to the next gzip member. | 413 | // continue to the next gzip member. |
@@ -450,7 +454,7 @@ ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, | |||
450 | 454 | ||
451 | // Continue until we have the requested data, the deflate data has | 455 | // Continue until we have the requested data, the deflate data has |
452 | // ended, or an error is encountered. | 456 | // ended, or an error is encountered. |
453 | } while (ret == Z_OK && left); | 457 | } while (ret == Z_OK); |
454 | inflateEnd(&strm); | 458 | inflateEnd(&strm); |
455 | 459 | ||
456 | // Return the number of uncompressed bytes read into buf, or the error. | 460 | // Return the number of uncompressed bytes read into buf, or the error. |