[poppler] Branch 'better_object' - 4 commits - fofi/FoFiType1.cc poppler/Error.cc poppler/GfxState.cc poppler/JPEG2000Stream.cc poppler/TextOutputDev.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue May 9 14:08:40 UTC 2017


 fofi/FoFiType1.cc         |    1 +
 poppler/Error.cc          |    8 ++++----
 poppler/GfxState.cc       |   10 +++++-----
 poppler/JPEG2000Stream.cc |    1 +
 poppler/TextOutputDev.cc  |    3 ++-
 5 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 79a52239c62763670e72cf22f69d5c709c72a932
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 9 16:08:18 2017 +0200

    JPXStreamPrivate::init2 - Fix memory leak in broken files

diff --git a/poppler/Error.cc b/poppler/Error.cc
index 99ca3ad3..f6c57844 100644
--- a/poppler/Error.cc
+++ b/poppler/Error.cc
@@ -85,11 +85,11 @@ void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...) {
     (*errorCbk)(errorCbkData, category, pos, sanitized->getCString());
   } else {
     if (pos >= 0) {
-      fprintf(stderr, "%s (%lld): %s\n",
-	      errorCategoryNames[category], (long long)pos, sanitized->getCString());
+//      fprintf(stderr, "%s (%lld): %s\n",
+//	      errorCategoryNames[category], (long long)pos, sanitized->getCString());
     } else {
-      fprintf(stderr, "%s: %s\n",
-	      errorCategoryNames[category], sanitized->getCString());
+//      fprintf(stderr, "%s: %s\n",
+//	      errorCategoryNames[category], sanitized->getCString());
     }
     fflush(stderr);
   }
diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc
index d20fa417..2b6af900 100644
--- a/poppler/JPEG2000Stream.cc
+++ b/poppler/JPEG2000Stream.cc
@@ -501,6 +501,7 @@ void JPXStreamPrivate::init2(OPJ_CODEC_FORMAT format, unsigned char *buf, int le
     return;
 
 error:
+  opj_stream_destroy(stream);
   opj_destroy_codec(decoder);
   if (format == OPJ_CODEC_JP2) {
     error(errSyntaxWarning, -1, "Did no succeed opening JPX Stream as JP2, trying as J2K.");
commit 270866ebac7920503c0856a5dd1e7937ab68dd5f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 9 14:34:57 2017 +0200

    GfxDeviceNColorSpace::parse - Fix memory leak on broken files

diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 61b462a8..a9e9bb4e 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -3048,7 +3048,6 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() {
 
 //~ handle the 'None' colorant
 GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) {
-  GfxDeviceNColorSpace *cs;
   int nCompsA;
   GooString *namesA[gfxColorMaxComps];
   GfxColorSpace *altA;
@@ -3093,7 +3092,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output
     obj1 = arr->get(4);
     if (!obj1.isDict()) {
       error(errSyntaxWarning, -1, "Bad DeviceN color space (attributes)");
-      goto err4;
+      goto err5;
     }
     Dict *attribs = obj1.getDict();
     Object obj2 = attribs->lookup("Colorants");
@@ -3105,14 +3104,15 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output
           separationList->append(GfxSeparationColorSpace::parse(res, obj3.getArray(), out, state, recursion));
         } else {
           error(errSyntaxWarning, -1, "Bad DeviceN color space (colorant value entry is not an Array)");
-          goto err4;
+          goto err5;
         }
       }
     }
   }
-  cs = new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList);
-  return cs;
+  return new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList);
 
+ err5:
+  delete funcA;
  err4:
   delete altA;
  err3:
commit 22123c836b35c1e8a1feb831899aacd991597c45
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 9 10:59:21 2017 +0200

    TextPool::addWord - Fix memory leak on broken files

diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index d9993e91..a89ba23c 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2006 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2007, 2008, 2012 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2008 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2008, 2010-2012, 2014-2016 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2010-2012, 2014-2017 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2008 Pino Toscano <pino at kde.org>
 // Copyright (C) 2008, 2010 Hib Eris <hib at hiberis.nl>
 // Copyright (C) 2009 Ross Moore <ross at maths.mq.edu.au>
@@ -891,6 +891,7 @@ void TextPool::addWord(TextWord *word) {
   // expand the array if needed
   if (unlikely((word->base / textPoolStep) > INT_MAX)) {
       error(errSyntaxWarning, -1, "word->base / textPoolStep > INT_MAX");
+      delete word;
       return;
   }
   wordBaseIdx = (int)(word->base / textPoolStep);
commit d7a102f49e2ea63c1cf3ed79134ce6fc2b2c6a59
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 9 10:50:27 2017 +0200

    FoFiType1::parse - Fix memory leak on broken files

diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc
index 151f2d5f..44f16972 100644
--- a/fofi/FoFiType1.cc
+++ b/fofi/FoFiType1.cc
@@ -276,6 +276,7 @@ void FoFiType1::parse() {
 	    if (code >= 0 && code < 256) {
 	      c = *p2;
 	      *p2 = '\0';
+	      gfree(encoding[code]);
 	      encoding[code] = copyString(p);
 	      *p2 = c;
 	    }


More information about the poppler mailing list