samtools / htslib

C library for high-throughput sequencing data formats
Other
785 stars 447 forks source link

Fix to 2e672f33 decompress_peek_gz change. #1646

Closed jkbonfield closed 11 months ago

jkbonfield commented 12 months ago

The "zs.total_out < destsize" should have been "zs.avail_out" to be more robust to total_out being reset by inflateReset. However looking again neither the avail_in or avail_out checks are necessary, as once we hit the end of either input or output buffer the next cycle triggers ret == Z_BUF_ERROR and we drop out as normal.

Thanks to John Marshall for the spot.

See #1643

daviesrob commented 11 months ago

Isn't the same problem still present in the main while loop? I.e.:

    while (zs.total_out < destsize) {

would be better done as:

    while (zs.avail_out > 0) {