mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Prevent failures in the "scanning for endstream" code, in Parser_makeStream
, by handling the case where 'endstream' is split between contiguous chunks (issue 1536)
This commit is contained in:
parent
051a0746e1
commit
15ce96a6eb
4 changed files with 32 additions and 13 deletions
|
@ -488,23 +488,22 @@ var Parser = (function ParserClosure() {
|
|||
break;
|
||||
}
|
||||
found = false;
|
||||
for (i = 0, j = 0; i < scanLength; i++) {
|
||||
var b = scanBytes[i];
|
||||
if (b !== ENDSTREAM_SIGNATURE[j]) {
|
||||
i -= j;
|
||||
j = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
while (i < scanLength) {
|
||||
j = 0;
|
||||
while (j < ENDSTREAM_SIGNATURE_LENGTH &&
|
||||
scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
|
||||
j++;
|
||||
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
|
||||
i++;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (found) {
|
||||
skipped += i - ENDSTREAM_SIGNATURE_LENGTH;
|
||||
stream.pos += i - ENDSTREAM_SIGNATURE_LENGTH;
|
||||
skipped += i;
|
||||
stream.pos += i;
|
||||
break;
|
||||
}
|
||||
skipped += scanLength;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue