File 0001-pdfunite-Fix-crash-with-broken-documents.patch of Package poppler.34111

Index: poppler-0.24.4/utils/pdfunite.cc
===================================================================
--- poppler-0.24.4.orig/utils/pdfunite.cc
+++ poppler-0.24.4/utils/pdfunite.cc
@@ -120,6 +120,10 @@ int main (int argc, char *argv[])
 
   for (i = 0; i < (int) docs.size(); i++) {
     for (j = 1; j <= docs[i]->getNumPages(); j++) {
+      if (!docs[i]->getCatalog()->getPage(j)) {
+        continue;
+      }
+
       PDFRectangle *cropBox = NULL;
       if (docs[i]->getCatalog()->getPage(j)->isCropped())
         cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
@@ -127,6 +131,14 @@ int main (int argc, char *argv[])
 	    docs[i]->getCatalog()->getPage(j)->getRotate(),
 	    docs[i]->getCatalog()->getPage(j)->getMediaBox(), cropBox, NULL);
       Ref *refPage = docs[i]->getCatalog()->getPageRef(j);
+      if (!refPage) {
+        fclose(f);
+        delete yRef;
+        delete countRef;
+        delete outStr;
+        error(errSyntaxError, -1, "PDFDoc::replacePageDict failed.");
+        return -1;
+      }
       Object page;
       docs[i]->getXRef()->fetch(refPage->num, refPage->gen, &page);
       if (!page.isDict()) {
openSUSE Build Service is sponsored by