Handle inflate on buffer larger than chunk size #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
In Zlib function
zlibBufferSync
:** it tries to handle a given buffer
** the default chunkSize is 16384
** it calls zlib method
_processChunk
in Zlib method
_processChunk
** there is a do-while loop calling
binding.writeSync
method to process the given buffer (parameter namedchunk
)** the chunkSize options is used as available out memory
** the do-while loop calls a function
callback
that is supposed to handle the case where the available out memory is not enough** the do-while loop breaks if there is an error in the writeSync process
in Zlib method
writeSync
** in calls
inflate
method and check returned status** if the status is not OK, it marks an error, making the do-while loop breaks
in
inflate
method:** in case
MATCH
: if there is no memory left, it breaks the for-loop**
ret
is Z_OK** condition flush === Z_FINISH and ret === Z_OK is turning ret to Z_BUF_ERROR
As a consequence :
Proposal
From: https://github.com/browserify/browserify-zlib/blob/master/src/binding.js#L241
_processChunk
can continue to handle large buffer