Don't throw when there isn't enough data to get block info in flate stream
but just ends the stream.
This commit is contained in:
parent
9d863f5180
commit
52ea20eda4
@ -19,8 +19,8 @@
|
|||||||
* license.
|
* license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { FormatError, info } from "../shared/util.js";
|
||||||
import { DecodeStream } from "./decode_stream.js";
|
import { DecodeStream } from "./decode_stream.js";
|
||||||
import { FormatError } from "../shared/util.js";
|
|
||||||
|
|
||||||
const codeLenCodeMap = new Int32Array([
|
const codeLenCodeMap = new Int32Array([
|
||||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
|
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
|
||||||
@ -238,6 +238,11 @@ class FlateStream extends DecodeStream {
|
|||||||
return [codes, maxLen];
|
return [codes, maxLen];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endsStreamOnError(err) {
|
||||||
|
info(err);
|
||||||
|
this.eof = true;
|
||||||
|
}
|
||||||
|
|
||||||
readBlock() {
|
readBlock() {
|
||||||
let buffer, len;
|
let buffer, len;
|
||||||
const str = this.str;
|
const str = this.str;
|
||||||
@ -253,19 +258,23 @@ class FlateStream extends DecodeStream {
|
|||||||
let b;
|
let b;
|
||||||
|
|
||||||
if ((b = str.getByte()) === -1) {
|
if ((b = str.getByte()) === -1) {
|
||||||
throw new FormatError("Bad block header in flate stream");
|
this.#endsStreamOnError("Bad block header in flate stream");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
let blockLen = b;
|
let blockLen = b;
|
||||||
if ((b = str.getByte()) === -1) {
|
if ((b = str.getByte()) === -1) {
|
||||||
throw new FormatError("Bad block header in flate stream");
|
this.#endsStreamOnError("Bad block header in flate stream");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
blockLen |= b << 8;
|
blockLen |= b << 8;
|
||||||
if ((b = str.getByte()) === -1) {
|
if ((b = str.getByte()) === -1) {
|
||||||
throw new FormatError("Bad block header in flate stream");
|
this.#endsStreamOnError("Bad block header in flate stream");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
let check = b;
|
let check = b;
|
||||||
if ((b = str.getByte()) === -1) {
|
if ((b = str.getByte()) === -1) {
|
||||||
throw new FormatError("Bad block header in flate stream");
|
this.#endsStreamOnError("Bad block header in flate stream");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
check |= b << 8;
|
check |= b << 8;
|
||||||
if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
|
if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
|
||||||
|
1
test/pdfs/issue17332.pdf.link
Normal file
1
test/pdfs/issue17332.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/13463186/test.1.pdf
|
@ -8372,5 +8372,14 @@
|
|||||||
"lastPage": 2,
|
"lastPage": 2,
|
||||||
"type": "eq",
|
"type": "eq",
|
||||||
"forms": true
|
"forms": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue17332-annotations",
|
||||||
|
"file": "pdfs/issue17332.pdf",
|
||||||
|
"md5": "140c34d900b797e1310b1cb142a4b8e3",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user