Bug 44659 - Segmentation fault of pdfunite on certain files
Summary: Segmentation fault of pdfunite on certain files
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-10 20:10 UTC by Arseny Solokha
Modified: 2012-01-13 09:53 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
gdb backtrace (1.15 KB, text/x-log)
2012-01-10 20:10 UTC, Arseny Solokha
Details

Description Arseny Solokha 2012-01-10 20:10:36 UTC
Created attachment 55403 [details]
gdb backtrace

There are some files that make pdfunite to segfault (backtrace attached). The crash is reproducible w/ either pdfunite 0.18.2 or built from today's git (master).

The following patch fixes the crash:

diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index df9cc06..b82869b 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -119,7 +119,7 @@ extern XpdfPluginVecTable xpdfPluginVecTable;
 
 //------------------------------------------------------------------------
 
-GlobalParams *globalParams = NULL;
+GlobalParams *globalParams = new GlobalParams(0);
 
 //------------------------------------------------------------------------
 // DisplayFontParam

(indeed, it introduces a memory leak).

Steps to reproduce:
% cp a.pdf b.pdf
% pdfunite a.pdf b.pdf c.pdf

The bug is reproducible w/ http://web.archive.org/web/20090122061701/http://www.free-culture.cc/freeculture.pdf or other files generated w/ certain versions of Acrobat Distiller (Acrobat Distiller 5.0.5 for Macintosh or Acrobat Distiller 8.1.0 (Windows), for example).
Comment 1 Albert Astals Cid 2012-01-10 23:07:10 UTC
That's not the correct fix, it is the pdfunite program that should instantiate the globalParams, i'll work on a fix later today if i have time.
Comment 2 Arseny Solokha 2012-01-10 23:25:25 UTC
(In reply to comment #1)
> That's not the correct fix, it is the pdfunite program that should instantiate
> the globalParams, i'll work on a fix later today if i have time.

OK, so the minimal fix (or workaround again?) is

--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -8,6 +8,7 @@
 //
 //========================================================================
 #include <PDFDoc.h>
+#include <GlobalParams.h>
 #include "parseargs.h"
 #include "config.h"
 #include <poppler-config.h>
@@ -66,6 +67,7 @@ int main (int argc, char *argv[])
     return exitCode;
   }
   exitCode = 0;
+  globalParams = new GlobalParams();
 
   for (i = 1; i < argc - 1; i++) {
     GooString *gfileName = new GooString(argv[i]);
@@ -172,5 +174,6 @@ int main (int argc, char *argv[])
   delete countRef;
   for (j = 0; j < (int) pages.size (); j++) pages[j].free();
   for (i = 0; i < (int) docs.size (); i++) delete docs[i];
+  delete globalParams;
   return exitCode;
 }
Comment 3 Albert Astals Cid 2012-01-13 09:53:04 UTC
Will be in next poppler 0.18 release


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.