mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #11577 from Snuffleupagus/Pages-tree-refs
Prevent circular references in the /Pages tree
This commit is contained in:
commit
e1586016c5
7 changed files with 155 additions and 8 deletions
|
@ -731,6 +731,7 @@ class Catalog {
|
|||
getPageDict(pageIndex) {
|
||||
const capability = createPromiseCapability();
|
||||
const nodesToVisit = [this.catDict.getRaw("Pages")];
|
||||
const visitedNodes = new RefSet();
|
||||
const xref = this.xref,
|
||||
pageKidsCountCache = this.pageKidsCountCache;
|
||||
let count,
|
||||
|
@ -747,6 +748,14 @@ class Catalog {
|
|||
currentPageIndex += count;
|
||||
continue;
|
||||
}
|
||||
// Prevent circular references in the /Pages tree.
|
||||
if (visitedNodes.has(currentNode)) {
|
||||
capability.reject(
|
||||
new FormatError("Pages tree contains circular reference.")
|
||||
);
|
||||
return;
|
||||
}
|
||||
visitedNodes.put(currentNode);
|
||||
|
||||
xref.fetchAsync(currentNode).then(function(obj) {
|
||||
if (isDict(obj, "Page") || (isDict(obj) && !obj.has("Kids"))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue