mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-11 06:10:57 +01:00
fix strm.avail_in check in wrappers
This commit is contained in:
parent
e555c41214
commit
13bfd6d9bf
2 changed files with 6 additions and 8 deletions
|
@ -131,6 +131,7 @@ var Deflate = function(options) {
|
|||
this.chunks = []; // chunks of compressed data
|
||||
|
||||
this.strm = new zstream();
|
||||
this.strm.avail_out = 0;
|
||||
|
||||
var status = zlib_deflate.deflateInit2(
|
||||
this.strm,
|
||||
|
@ -193,7 +194,6 @@ Deflate.prototype.push = function(data, mode) {
|
|||
|
||||
strm.next_in_index = 0;
|
||||
strm.avail_in = strm.next_in.length;
|
||||
strm.avail_out = 0;
|
||||
|
||||
do {
|
||||
if (strm.avail_out === 0) {
|
||||
|
@ -208,7 +208,7 @@ Deflate.prototype.push = function(data, mode) {
|
|||
this.ended = true;
|
||||
return false;
|
||||
}
|
||||
if (strm.avail_out === 0 || strm.avail_in === 0) {
|
||||
if (strm.avail_out === 0 || (strm.avail_in === 0 && _mode === Z_FINISH)) {
|
||||
if (this.options.to === 'string') {
|
||||
this.onData(utils.buf2binstring(utils.shrinkBuf(strm.next_out, strm.next_out_index)));
|
||||
} else {
|
||||
|
|
|
@ -129,6 +129,7 @@ var Inflate = function(options) {
|
|||
this.chunks = []; // chunks of compressed data
|
||||
|
||||
this.strm = new zstream();
|
||||
this.strm.avail_out = 0;
|
||||
|
||||
var status = zlib_inflate.inflateInit2(
|
||||
this.strm,
|
||||
|
@ -181,7 +182,7 @@ Inflate.prototype.push = function(data, mode) {
|
|||
var next_out_utf8_index, tail, utf8str;
|
||||
|
||||
if (this.ended) { return false; }
|
||||
_mode = c.Z_NO_FLUSH;
|
||||
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
||||
|
||||
// Convert data if needed
|
||||
if (typeof data === 'string') {
|
||||
|
@ -193,7 +194,6 @@ Inflate.prototype.push = function(data, mode) {
|
|||
|
||||
strm.next_in_index = 0;
|
||||
strm.avail_in = strm.next_in.length;
|
||||
strm.avail_out = 0;
|
||||
|
||||
do {
|
||||
if (strm.avail_out === 0) {
|
||||
|
@ -202,7 +202,7 @@ Inflate.prototype.push = function(data, mode) {
|
|||
strm.avail_out = chunkSize;
|
||||
}
|
||||
|
||||
status = zlib_inflate.inflate(strm, _mode); /* no bad return value */
|
||||
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
||||
|
||||
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
||||
this.onEnd(status);
|
||||
|
@ -211,7 +211,7 @@ Inflate.prototype.push = function(data, mode) {
|
|||
}
|
||||
|
||||
if (strm.next_out_index) {
|
||||
if (strm.avail_out === 0 || strm.avail_in === 0 || status === c.Z_STREAM_END) {
|
||||
if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && _mode === c.Z_FINISH)) {
|
||||
|
||||
if (this.to === 'string') {
|
||||
|
||||
|
@ -249,8 +249,6 @@ Inflate.prototype.push = function(data, mode) {
|
|||
|
||||
if (status === c.Z_STREAM_END) {
|
||||
_mode = c.Z_FINISH;
|
||||
} else {
|
||||
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
||||
}
|
||||
// Finalize on the last chunk.
|
||||
if (_mode === c.Z_FINISH) {
|
||||
|
|
Loading…
Add table
Reference in a new issue