fix for uncompressed flatestream blocks
This commit is contained in:
parent
3f2bbbe919
commit
18afc896f6
20
pdf.js
20
pdf.js
@ -479,17 +479,17 @@ var FlateStream = (function() {
|
|||||||
array[i++] = what;
|
array[i++] = what;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bytes = this.bytes;
|
|
||||||
var bytesPos = this.bytesPos;
|
|
||||||
|
|
||||||
// read block header
|
// read block header
|
||||||
var hdr = this.getBits(3);
|
var hdr = this.getBits(3);
|
||||||
if (hdr & 1)
|
if (hdr & 1)
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
hdr >>= 1;
|
hdr >>= 1;
|
||||||
|
|
||||||
var b;
|
|
||||||
if (hdr == 0) { // uncompressed block
|
if (hdr == 0) { // uncompressed block
|
||||||
|
var bytes = this.bytes;
|
||||||
|
var bytesPos = this.bytesPos;
|
||||||
|
var b;
|
||||||
|
|
||||||
if (typeof (b = bytes[bytesPos++]) == "undefined")
|
if (typeof (b = bytes[bytesPos++]) == "undefined")
|
||||||
error("Bad block header in flate stream");
|
error("Bad block header in flate stream");
|
||||||
var blockLen = b;
|
var blockLen = b;
|
||||||
@ -502,18 +502,24 @@ var FlateStream = (function() {
|
|||||||
if (typeof (b = bytes[bytesPos++]) == "undefined")
|
if (typeof (b = bytes[bytesPos++]) == "undefined")
|
||||||
error("Bad block header in flate stream");
|
error("Bad block header in flate stream");
|
||||||
check |= (b << 8);
|
check |= (b << 8);
|
||||||
if (check != (~this.blockLen & 0xffff))
|
if (check != (~blockLen & 0xffff))
|
||||||
error("Bad uncompressed block length in flate stream");
|
error("Bad uncompressed block length in flate stream");
|
||||||
|
|
||||||
|
this.codeBuf = 0;
|
||||||
|
this.codeSize = 0;
|
||||||
|
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var buffer = this.ensureBuffer(bufferLength + blockLen);
|
var buffer = this.ensureBuffer(bufferLength + blockLen);
|
||||||
this.bufferLength = bufferLength + blockLen;
|
var end = bufferLength + blockLen;
|
||||||
for (var n = bufferLength; n < blockLen; ++n) {
|
this.bufferLength = end;
|
||||||
|
for (var n = bufferLength; n < end; ++n) {
|
||||||
if (typeof (b = bytes[bytesPos++]) == "undefined") {
|
if (typeof (b = bytes[bytesPos++]) == "undefined") {
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer[n] = b;
|
buffer[n] = b;
|
||||||
}
|
}
|
||||||
|
this.bytesPos = bytesPos;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user