diff options
author | Albert Astals Cid <aacid@kde.org> | 2022-10-19 21:15:29 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2022-10-19 21:15:29 +0200 |
commit | e53f5aae3bce7d09788f2ad62be998895fb9807b (patch) | |
tree | 89338492ab7826f9fa970181b5f4d597c4319d4e | |
parent | a4ca3a96a6b1f65b335a1ea362e6c202e46ae055 (diff) |
PSOutputDev::setupResources: Fix stack overflow in malformed doc
Issue #1304
-rw-r--r-- | poppler/PSOutputDev.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 66a49f2b..cdabc251 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1908,8 +1908,13 @@ void PSOutputDev::setupResources(Dict *resDict) // process the Pattern's resource dictionary Object pat = patDict.dictGetVal(i); if (pat.isStream()) { - Object resObj = pat.streamGetDict()->lookup("Resources"); + Ref resObjRef; + Object resObj = pat.streamGetDict()->lookup("Resources", &resObjRef); if (resObj.isDict()) { + if (resObjRef != Ref::INVALID() && !resourceIDs.insert(resObjRef.num).second) { + error(errSyntaxWarning, -1, "PSOutputDev::setupResources: Circular resources found."); + continue; + } setupResources(resObj.getDict()); } } |