diff options
author | John Högberg <[email protected]> | 2017-11-07 17:24:55 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2017-11-09 08:23:20 +0100 |
commit | 8cfe9496873fa36eccda939e56bf7a922e945ca9 (patch) | |
tree | 0b7c43c6c45fd0e87e680f734c0ceb0187c95187 /erts/preloaded/src/zlib.erl | |
parent | 3e8c1ff94c0a73df71daadd4eb782c21c49f22d9 (diff) | |
download | otp-8cfe9496873fa36eccda939e56bf7a922e945ca9.tar.gz otp-8cfe9496873fa36eccda939e56bf7a922e945ca9.tar.bz2 otp-8cfe9496873fa36eccda939e56bf7a922e945ca9.zip |
Fix deflateParams on zlib 1.2.11
1.2.11 started bailing when avail_out==0 regardless of whether
there's anything to flush or not, and there's no point in adapting
the old method since it was vulnerable to bugs in other zlib
versions which updated the deflate parameters even on failure.
The api_deflateParams test has been expanded accordingly, and two
white-box cases in zip_usage has been updated to make fewer
assumptions about the output; the validity of the compressed data
is what matters, not whether it's exactly the same as the test
vector.
Diffstat (limited to 'erts/preloaded/src/zlib.erl')
-rw-r--r-- | erts/preloaded/src/zlib.erl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/erts/preloaded/src/zlib.erl b/erts/preloaded/src/zlib.erl index 03c9ae38a1..a4ef42204d 100644 --- a/erts/preloaded/src/zlib.erl +++ b/erts/preloaded/src/zlib.erl @@ -188,14 +188,13 @@ deflateReset_nif(_Z) -> deflateParams(Z, Level0, Strategy0) -> Level = arg_level(Level0), Strategy = arg_strategy(Strategy0), + Progress = deflate(Z, <<>>, sync), case deflateParams_nif(Z, Level, Strategy) of - buf_error -> - %% We had data left in the pipe; flush everything and stash it away - %% for the next deflate call before trying again. - Output = deflate(Z, <<>>, full), - save_progress(Z, deflate, Output), - deflateParams_nif(Z, Level, Strategy); - Any -> Any + ok -> + save_progress(Z, deflate, Progress), + ok; + Other -> + Other end. deflateParams_nif(_Z, _Level, _Strategy) -> erlang:nif_error(undef). |