kopia lustrzana https://github.com/viljoviitanen/pako
fix inflate wrapper check condition, issue #65
rodzic
2bef4935c7
commit
2c504a0865
|
@ -177,6 +177,8 @@ Inflate.prototype.push = function(data, mode) {
|
||||||
var chunkSize = this.options.chunkSize;
|
var chunkSize = this.options.chunkSize;
|
||||||
var status, _mode;
|
var status, _mode;
|
||||||
var next_out_utf8, tail, utf8str;
|
var next_out_utf8, tail, utf8str;
|
||||||
|
// allow Z_BUF_ERROR on next inflate call
|
||||||
|
var allowBufError = 0;
|
||||||
|
|
||||||
if (this.ended) { return false; }
|
if (this.ended) { return false; }
|
||||||
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
||||||
|
@ -203,6 +205,11 @@ Inflate.prototype.push = function(data, mode) {
|
||||||
|
|
||||||
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
||||||
|
|
||||||
|
if (status === c.Z_BUF_ERROR && allowBufError === 1) {
|
||||||
|
status = c.Z_OK;
|
||||||
|
allowBufError = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
||||||
this.onEnd(status);
|
this.onEnd(status);
|
||||||
this.ended = true;
|
this.ended = true;
|
||||||
|
@ -231,7 +238,11 @@ Inflate.prototype.push = function(data, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((strm.avail_in > 0) && status !== c.Z_STREAM_END);
|
// we need to check internal inflate buffers and state but inflate can return Z_BUF_ERROR if no output
|
||||||
|
if (strm.avail_in === 0 && strm.avail_out === 0) {
|
||||||
|
allowBufError = 1;
|
||||||
|
}
|
||||||
|
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
|
||||||
|
|
||||||
if (status === c.Z_STREAM_END) {
|
if (status === c.Z_STREAM_END) {
|
||||||
_mode = c.Z_FINISH;
|
_mode = c.Z_FINISH;
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Ładowanie…
Reference in New Issue