#1298·zlib

[doc] zlib.h: windowBits Z_DATA_ERROR guarantee doesn't hold for raw or gzip

Author: JasonGrossCreated Aug 19, 2026Updated Aug 19, 2026

https://github.com/madler/zlib/blob/e3dc0a85b7032e98380dec011bc8f2c2ee0d8fca/zlib.h#L866-L873

For raw and gzip streams, which don't declare a window size in the header, if the caller provides a large enough output buffer, then the decompression may succeed despite requiring a larger window size than provided; the Z_DATA_ERROR seems to be triggered only when match distance exceeds the window + already written data in the buffer.

I presume this is only an issue with the documentation and not with the code. (It confused my LLM, I figured I'd report it here in case clarifying the documentation is useful.)