- /* If flushing or finishing and all input has been consumed, then done. If
- * the code above couldn't write a complete block to next_out, then the
- * code following this won't be able to either.
- */
- if (flush != Z_NO_FLUSH && s->strm->avail_in == 0 &&
- (long)s->strstart == s->block_start)
- return flush == Z_FINISH ? finish_done : block_done;
+ /* If the last block was written to next_out, then done. */
+ if (last)
+ return finish_done;
+
+ /* If flushing and all input has been consumed, then done. */
+ if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
+ s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
+ return block_done;