mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-11 22:31:00 +01:00
Polished ungzip crc32 check
This commit is contained in:
parent
1d91d3b187
commit
21c21df425
1 changed files with 4 additions and 3 deletions
|
@ -1356,8 +1356,8 @@ function inflate(strm, flush) {
|
||||||
while (bits < 32) {
|
while (bits < 32) {
|
||||||
if (have === 0) { break inf_leave; }
|
if (have === 0) { break inf_leave; }
|
||||||
have--;
|
have--;
|
||||||
hold += input[next++] << bits;
|
// Use '|' insdead of '+' to make sure that result is signed
|
||||||
hold >>>= 0;
|
hold |= input[next++] << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
//===//
|
//===//
|
||||||
|
@ -1371,7 +1371,8 @@ function inflate(strm, flush) {
|
||||||
|
|
||||||
}
|
}
|
||||||
_out = left;
|
_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';
|
strm.msg = 'incorrect data check';
|
||||||
state.mode = BAD;
|
state.mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue