Introduce Dict::getVal(int i, Ref *returnRef)
And use it in FontInfoScanner::scanFonts
diff --git a/poppler/Dict.cc b/poppler/Dict.cc
index 17c2f98..524a862 100644
--- a/poppler/Dict.cc
+++ b/poppler/Dict.cc
@@ -202,6 +202,17 @@
return false;
}
+Object Dict::getVal(int i, Ref *returnRef) const
+{
+ const DictEntry &entry = entries[i];
+ if (entry.second.getType() == objRef) {
+ *returnRef = entry.second.getRef();
+ } else {
+ *returnRef = Ref::INVALID();
+ }
+ return entry.second.fetch(xref);
+}
+
bool Dict::hasKey(const char *key) const {
return find(key) != nullptr;
}
diff --git a/poppler/Dict.h b/poppler/Dict.h
index 6c1424a..287d5a3 100644
--- a/poppler/Dict.h
+++ b/poppler/Dict.h
@@ -84,6 +84,8 @@
// Iterative accessors.
const char *getKey(int i) const { return entries[i].first.c_str(); }
Object getVal(int i) const { return entries[i].second.fetch(xref); }
+ // Same as above but if the returned object is a fetched Ref returns such Ref in returnRef, otherwise returnRef is Ref::INVALID()
+ Object getVal(int i, Ref *returnRef) const;
const Object &getValNF(int i) const { return entries[i].second; }
// Set the xref pointer. This is only used in one special case: the
diff --git a/poppler/FontInfo.cc b/poppler/FontInfo.cc
index cd33577..b7e970d 100644
--- a/poppler/FontInfo.cc
+++ b/poppler/FontInfo.cc
@@ -131,18 +131,17 @@
Object objDict = resDict->lookup(resTypes[resType]);
if (objDict.isDict()) {
for (int i = 0; i < objDict.dictGetLength(); ++i) {
- const Object &dictObjI = objDict.dictGetValNF(i);
- if (dictObjI.isRef()) {
+ Ref obj2Ref;
+ const Object obj2 = objDict.getDict()->getVal(i, &obj2Ref);
+ if (obj2Ref != Ref::INVALID()) {
// check for an already-seen object
- const Ref r = dictObjI.getRef();
- if (visitedObjects.find(r.num) != visitedObjects.end()) {
+ if (visitedObjects.find(obj2Ref.num) != visitedObjects.end()) {
continue;
}
- visitedObjects.insert(r.num);
+ visitedObjects.insert(obj2Ref.num);
}
- Object obj2 = dictObjI.fetch(xrefA);
if (obj2.isStream()) {
Ref resourcesRef;
const Object resObj = obj2.streamGetDict()->lookup("Resources", &resourcesRef);