mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Avoid infinite loop when getting annotation field name
- aims to fix issue #12963; - use a Set to track already visited objects; - remove the loop limit in getInheritableProperty and use a RefSet too.
This commit is contained in:
parent
f892c00275
commit
0fc8267576
6 changed files with 39 additions and 36 deletions
|
@ -123,30 +123,6 @@ describe("core_utils", function () {
|
|||
["qux2", "quux"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("stops searching when the loop limit is reached", function () {
|
||||
const dict = new Dict();
|
||||
let currentDict = dict;
|
||||
let parentDict = null;
|
||||
// Exceed the loop limit of 100.
|
||||
for (let i = 0; i < 150; i++) {
|
||||
parentDict = new Dict();
|
||||
currentDict.set("Parent", parentDict);
|
||||
currentDict = parentDict;
|
||||
}
|
||||
parentDict.set("foo", "bar"); // Never found because of loop limit.
|
||||
expect(getInheritableProperty({ dict, key: "foo" })).toEqual(undefined);
|
||||
|
||||
dict.set("foo", "baz");
|
||||
expect(
|
||||
getInheritableProperty({
|
||||
dict,
|
||||
key: "foo",
|
||||
getArray: false,
|
||||
stopWhenFound: false,
|
||||
})
|
||||
).toEqual(["baz"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toRomanNumerals", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue