Commit e494ea6 for zlib
commit e494ea67761800024fbb28c6f72c85574b7ad0e1
Author: fhgffy <102001626+fhgffy@users.noreply.github.com>
Date: Sun Oct 4 22:11:49 2026 +0800
Fix raw deflate completion at exact output capacity.
Before this, raw deflate that just filled the provided buffer and
completed would return Z_OK. It now returns Z_STREAM_END, as
promised in zlib.h.
diff --git a/deflate.c b/deflate.c
index 6f25c31..fd83075 100644
--- a/deflate.c
+++ b/deflate.c
@@ -1652,7 +1652,10 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* Same but force premature exit if necessary. */
#define FLUSH_BLOCK(s, last) { \
FLUSH_BLOCK_ONLY(s, last); \
- if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
+ if (s->strm->avail_out == 0) { \
+ if (!(last)) return need_more; \
+ if (s->pending != 0 || s->wrap != 0) return finish_started; \
+ } \
}
/* Maximum stored block length in deflate format (not including header). */