From ec48820c3cf8ead0add464c60f5dddd84ba0097d Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 4 Apr 2021 17:22:07 -0400 Subject: Fix loop detection in NNTree --- libqpdf/NNTree.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'libqpdf') 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 seen; + for (auto i: this->path) + { + if (i.node.isIndirect()) + { + seen.insert(i.node.getObjGen()); + } + } while (! failed) { if (node.isIndirect()) -- cgit v1.2.3-54-g00ecf