Skip to content

Commit

Permalink
PdfDictionary: Fix circular reference lookup
Browse files Browse the repository at this point in the history
Should fix #66
  • Loading branch information
ceztko committed Apr 12, 2023
1 parent 657c46c commit 8d3e910
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/podofo/main/PdfDictionary.cpp
Expand Up @@ -146,18 +146,19 @@ PdfObject* PdfDictionary::findKey(const string_view& key) const
PdfObject* PdfDictionary::findKeyParent(const string_view& key) const
{
utls::RecursionGuard guard;
PdfObject* obj = findKey(key);
auto obj = findKey(key);
if (obj == nullptr)
{
PdfObject* parent = findKey("Parent");
if (parent == nullptr)
auto parent = findKey("Parent");
if (parent == nullptr || parent->GetIndirectReference() == GetOwner()->GetIndirectReference())
{
return nullptr;
}
else
{
if (parent->IsDictionary())
return parent->GetDictionary().findKeyParent(key);
PdfDictionary* parentDict;
if (parent->TryGetDictionary(parentDict))
return parentDict->findKeyParent(key);
else
return nullptr;
}
Expand Down

0 comments on commit 8d3e910

Please sign in to comment.