Skip to content

Commit

Permalink
Fix loop detection in NNTree
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkenbilt committed Apr 5, 2021
1 parent 258675f commit ec48820
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libqpdf/NNTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
Binary file modified qpdf/qtest/qpdf/name-tree.pdf
Binary file not shown.

0 comments on commit ec48820

Please sign in to comment.