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:
Calixte Denizet 2021-02-06 12:23:35 +01:00
parent f892c00275
commit 0fc8267576
6 changed files with 39 additions and 36 deletions

View file

@ -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 () {