Polished ungzip crc32 check

master
Vitaly Puzrin 2014-03-13 23:43:30 +04:00
rodzic 1d91d3b187
commit 21c21df425
1 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -1356,8 +1356,8 @@ function inflate(strm, flush) {
while (bits < 32) {
if (have === 0) { break inf_leave; }
have--;
hold += input[next++] << bits;
hold >>>= 0;
// Use '|' insdead of '+' to make sure that result is signed
hold |= input[next++] << bits;
bits += 8;
}
//===//
@ -1371,7 +1371,8 @@ function inflate(strm, flush) {
}
_out = left;
if ((state.flags ? hold : ZSWAP32(hold) >>> 0) !== state.check >>> 0) {
// NB: crc32 stored as signed 32-bit int, ZSWAP32 returns signed too
if ((state.flags ? hold : ZSWAP32(hold)) !== state.check) {
strm.msg = 'incorrect data check';
state.mode = BAD;
break;