Skip to content

Commit

Permalink
Merge pull request mozilla#15834 from Snuffleupagus/issue-15833
Browse files Browse the repository at this point in the history
Always parse the entire `startXRefQueue` in `XRef.readXRef` (issue 15833)
  • Loading branch information
Snuffleupagus authored Dec 15, 2022
2 parents 0021d65 + 26135b0 commit 826c358
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/core/xref.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ class XRef {
// circular dependency between tables (fixes bug1393476.pdf).
const startXRefParsedCache = new Set();

try {
while (this.startXRefQueue.length) {
while (this.startXRefQueue.length) {
try {
const startXRef = this.startXRefQueue[0];

if (startXRefParsedCache.has(startXRef)) {
Expand Down Expand Up @@ -734,20 +734,18 @@ class XRef {
// This is a fallback for non-compliant PDFs, i.e. "/Prev NNN 0 R"
this.startXRefQueue.push(obj.num);
}

this.startXRefQueue.shift();
}

return this.topDict;
} catch (e) {
if (e instanceof MissingDataException) {
throw e;
} catch (e) {
if (e instanceof MissingDataException) {
throw e;
}
info("(while reading XRef): " + e);
}
info("(while reading XRef): " + e);

this.startXRefQueue.shift();
}

if (this.topDict) {
return this.topDict;
}
if (recoveryMode) {
return undefined;
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue15833.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/10236962/issue15833.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,14 @@
"37R": false
}
},
{ "id": "issue15833",
"file": "pdfs/issue15833.pdf",
"md5": "9562d027b980ea2779dcfb1669f9cf7e",
"link": true,
"rounds": 1,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue11242",
"file": "pdfs/issue11242_reduced.pdf",
"md5": "ba50b6ee537f3e815ccfe0c99e598e05",
Expand Down

0 comments on commit 826c358

Please sign in to comment.