File 0001-Fix-memory-leak-when-reconstructing-broken-files.patch of Package poppler.8309

From b21b041f7948680c03109f0c404400a9dbc4544c Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Tue, 25 Apr 2017 19:48:24 +0200
Subject: [PATCH] Fix memory leak when reconstructing broken files

Need to free the catalog variable if we're going to fetch over it again

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

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) {
-- 
2.13.0