Skip to content

Commit 1c12491

Browse files
committed
Fix zlib.inflate filter
If `inflate()` is called with flush mode `Z_FINISH`, but the output buffer is not large enough to inflate all available data, it fails with `Z_BUF_ERROR`. However, `Z_BUF_ERROR` is not fatal; in fact, the zlib manual states: "If deflate returns with Z_OK or Z_BUF_ERROR, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error." Hence, we do so. This fixes the so far failing ext/soap/tests/bug73037.phpt.
1 parent 80955dd commit 1c12491

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/zlib/zlib_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
9090
inflateEnd(&(data->strm));
9191
data->finished = '\1';
9292
exit_status = PSFS_PASS_ON;
93-
} else if (status != Z_OK) {
93+
} else if (status != Z_OK && status != Z_BUF_ERROR) {
9494
/* Something bad happened */
9595
php_stream_bucket_delref(bucket);
9696
/* reset these because despite the error the filter may be used again */

0 commit comments

Comments
 (0)