memorysafety / zlib-rs

A safer zlib
zlib License
75 stars 6 forks source link

`flush` is not respected in `inflate()` #114

Closed cjgriscom closed 3 weeks ago

cjgriscom commented 3 weeks ago

The state handler in the original inflate.c references the flush parameter to inflate() where it modifies the exit behavior based on this condition:

case TYPE:
    if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
    /* fallthrough */
case TYPEDO:

Now, this case is already correctly implemented in zlib-rs, but since the state handler has been moved out of inflate(), it must reference state.flush, which is never assigned.

I made a PR to address this and get FLUSH_BLOCK working properly. https://github.com/memorysafety/zlib-rs/pull/113