This commit adds a testcase that fails because of an apparent bug in miniz_oxide. The bug happens when it just so happens that both input buffer becomes empty and output buffer becomes full during the same call to the inflate::core::decompress function. In that case, I think that most users of the library expect to get HasMoreOutput status, urging them to read the output value before it gets overwritten by another decompress call.
However, in some (but only in some) cases, NeedsMoreInput status is returned. If the user naively pattern-matches to the status and calls again with more input, data loss occurs. Therefore, when the output buffer is full, HasMoreOutput should always be prioritized over NeedsMoreInput.
I don't still know enough about the insides of this library to suggest a fix in the same PR. However, at least I was able to reduce the bug into a relatively simple case.
This commit adds a testcase that fails because of an apparent bug in miniz_oxide. The bug happens when it just so happens that both input buffer becomes empty and output buffer becomes full during the same call to the
inflate::core::decompress
function. In that case, I think that most users of the library expect to getHasMoreOutput
status, urging them to read the output value before it gets overwritten by anotherdecompress
call.However, in some (but only in some) cases,
NeedsMoreInput
status is returned. If the user naively pattern-matches to the status and calls again with more input, data loss occurs. Therefore, when the output buffer is full,HasMoreOutput
should always be prioritized overNeedsMoreInput
.I don't still know enough about the insides of this library to suggest a fix in the same PR. However, at least I was able to reduce the bug into a relatively simple case.