fix inflate wrapper check condition, issue #65

master
nik 2015-09-12 17:19:40 +03:00 zatwierdzone przez Vitaly Puzrin
rodzic 2bef4935c7
commit 2c504a0865
3 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -177,6 +177,8 @@ Inflate.prototype.push = function(data, mode) {
var chunkSize = this.options.chunkSize;
var status, _mode;
var next_out_utf8, tail, utf8str;
// allow Z_BUF_ERROR on next inflate call
var allowBufError = 0;
if (this.ended) { return false; }
_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 */
if (status === c.Z_BUF_ERROR && allowBufError === 1) {
status = c.Z_OK;
allowBufError = 0;
}
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
this.onEnd(status);
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) {
_mode = c.Z_FINISH;

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.