[poppler] poppler/XRef.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Apr 25 17:49:26 UTC 2017


 poppler/XRef.cc |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit b21b041f7948680c03109f0c404400a9dbc4544c
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Apr 25 19:48:24 2017 +0200

    Fix memory leak when reconstructing broken files
    
    Need to free the catalog variable if we're going to fetch over it again
    
    Bug #100776

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index c141bbfe..6ea0fbb6 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1144,13 +1144,16 @@ GBool XRef::okToAssemble(GBool ignoreOwnerPW) {
 }
 
 Object *XRef::getCatalog(Object *catalog) {
-  Object *obj = fetch(rootNum, rootGen, catalog);
-  if (obj->isDict()) {
-    return obj;
+  fetch(rootNum, rootGen, catalog);
+  if (catalog->isDict()) {
+    return catalog;
   }
   GBool wasReconstructed = false;
-  GBool ok = constructXRef(&wasReconstructed, gTrue);
-  return (ok) ? fetch(rootNum, rootGen, catalog) : obj;
+  if (constructXRef(&wasReconstructed, gTrue)) {
+    catalog->free();
+    fetch(rootNum, rootGen, catalog);
+  }
+  return catalog;
 }
 
 Object *XRef::fetch(int num, int gen, Object *obj, int recursion) {


More information about the poppler mailing list