[poppler] Branch 'poppler-0.16' - 3 commits - poppler/Catalog.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Jun 4 05:26:58 PDT 2011


 poppler/Catalog.cc |   30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 305c5a8e6b9d79fc0648417da1035b19b628b67d
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Jun 4 13:23:11 2011 +0100

    Make sure catDict is a dict
    (cherry picked from commit db2ae1bdbb7fcb64ba4c91dfc574d9f970bebdf6)

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 49b585a..9e666bd 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -846,6 +846,11 @@ int Catalog::getNumPages()
     Object catDict, pagesDict, obj;
 
     xref->getCatalog(&catDict);
+    if (!catDict.isDict()) {
+      error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+      catDict.free();
+      return 0;
+    }
     catDict.dictLookup("Pages", &pagesDict);
     catDict.free();
 
commit a0f200f38d47fba8f1cf0c078800ce0f8acbb208
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Jun 4 13:20:02 2011 +0100

    Make sure catDict is a dict before using it
    
    KDE Bug 274888 shows it's possible to get aborts because of that
    (cherry picked from commit 58915affbdf1b5780f25d172a582c69fb2413230)

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index d48692c..49b585a 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -230,17 +230,23 @@ GBool Catalog::cachePageTree(int page)
 
     xref->getCatalog(&catDict);
 
-    Object pagesDictRef;
-    if (catDict.dictLookupNF("Pages", &pagesDictRef)->isRef() &&
-        pagesDictRef.getRefNum() >= 0 &&
-        pagesDictRef.getRefNum() < xref->getNumObjects()) {
-      pagesRef = pagesDictRef.getRef();
-      pagesDictRef.free();
+    if (catDict.isDict()) {
+      Object pagesDictRef;
+      if (catDict.dictLookupNF("Pages", &pagesDictRef)->isRef() &&
+          pagesDictRef.getRefNum() >= 0 &&
+          pagesDictRef.getRefNum() < xref->getNumObjects()) {
+        pagesRef = pagesDictRef.getRef();
+        pagesDictRef.free();
+      } else {
+        error(-1, "Catalog dictionary does not contain a valid \"Pages\" entry");
+        pagesDictRef.free();
+        catDict.free();
+        return gFalse;
+      }
     } else {
-       error(-1, "Catalog dictionary does not contain a valid \"Pages\" entry");
-       pagesDictRef.free();
-       catDict.free();
-       return gFalse;
+      error(-1, "Could not find catalog dictionary");
+      catDict.free();
+      return gFalse;
     }
 
     Object obj;
commit 7e1e4cb7fe2be271f160a886f6796afc5738b416
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Jun 4 13:19:34 2011 +0100

    We need to free catDict on failure
    (cherry picked from commit 4ebc7e364409fe303e7a5729b568913e3c92e7d4)

diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 7decc72..d48692c 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -239,6 +239,7 @@ GBool Catalog::cachePageTree(int page)
     } else {
        error(-1, "Catalog dictionary does not contain a valid \"Pages\" entry");
        pagesDictRef.free();
+       catDict.free();
        return gFalse;
     }
 


More information about the poppler mailing list