aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/NNTree.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-04-04 23:22:07 +0200
committerJay Berkenbilt <ejb@ql.org>2021-04-05 13:59:02 +0200
commitec48820c3cf8ead0add464c60f5dddd84ba0097d (patch)
tree4457b4b31ca82fe66a9fbf3937fda8468928f915 /libqpdf/NNTree.cc
parent258675fc9935fe20fddb33163b6372aaab5dab04 (diff)
downloadqpdf-ec48820c3cf8ead0add464c60f5dddd84ba0097d.tar.zst
Fix loop detection in NNTree
Diffstat (limited to 'libqpdf/NNTree.cc')
-rw-r--r--libqpdf/NNTree.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc
index 2658ffe8..abef2964 100644
--- a/libqpdf/NNTree.cc
+++ b/libqpdf/NNTree.cc
@@ -450,8 +450,8 @@ NNTreeIterator::split(QPDFObjectHandle to_split,
// CURRENT STATE: half the items from the kids or items array in
// the node being split have been moved into a new node. The new
- // node is not yet attached to the tree. The iterator have a path
- // element or leaf node that is out of bounds.
+ // node is not yet attached to the tree. The iterator may have a
+ // path element or leaf node that is out of bounds.
// We need to adjust the parent to add the second node to /Kids
// and, if needed, update kid_number to traverse through it. We
@@ -748,6 +748,13 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
bool failed = false;
std::set<QPDFObjGen> seen;
+ for (auto i: this->path)
+ {
+ if (i.node.isIndirect())
+ {
+ seen.insert(i.node.getObjGen());
+ }
+ }
while (! failed)
{
if (node.isIndirect())