[poppler] Branch 'poppler-0.18' - poppler/Gfx.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Nov 11 07:39:49 PST 2011


 poppler/Gfx.cc |   52 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 23 deletions(-)

New commits:
commit 8b4d6056e0a56fec31ff648a01d88d5942f36b0b
Author: Albert Astals Cid <aacid at kde.org>
Date:   Fri Nov 11 16:37:27 2011 +0100

    Do not crash if failing to parse the colorspace
    
    Fixes bug 42793
    (cherry picked from commit f6d026bfa18624ccd321e102bb39ba744998de1e)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index bca60e2..2f481f0 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1319,7 +1319,7 @@ void Gfx::opSetRenderingIntent(Object args[], int numArgs) {
 
 void Gfx::opSetFillGray(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
 
   if (textHaveCSPattern && drawText) {
@@ -1332,11 +1332,12 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
   }
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
-  if (obj.isNull()) {
-    colorSpace = new GfxDeviceGrayColorSpace();
-  } else {
+  if (!obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceGrayColorSpace();
+  }
   obj.free();
   state->setFillColorSpace(colorSpace);
   out->updateFillColorSpace(state);
@@ -1354,16 +1355,17 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
 
 void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
 
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultGray", &obj);
-  if (obj.isNull()) {
-    colorSpace = new GfxDeviceGrayColorSpace();
-  } else {
+  if (!obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceGrayColorSpace();
+  }
   obj.free();
   state->setStrokeColorSpace(colorSpace);
   out->updateStrokeColorSpace(state);
@@ -1374,7 +1376,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) {
 
 void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
   int i;
 
@@ -1387,11 +1389,12 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
     out->restoreState(state);
   }
   res->lookupColorSpace("DefaultCMYK", &obj);
-  if (obj.isNull()) {
-    colorSpace = new GfxDeviceCMYKColorSpace();
-  } else {
+  if (!obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceCMYKColorSpace();
+  }
   obj.free();
   state->setFillPattern(NULL);
   state->setFillColorSpace(colorSpace);
@@ -1412,17 +1415,18 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
 
 void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
   int i;
 
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultCMYK", &obj);
-  if (obj.isNull()) {
-    colorSpace = new GfxDeviceCMYKColorSpace();
-  } else {
+  if (!obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceCMYKColorSpace();
+  }
   obj.free();
   state->setStrokeColorSpace(colorSpace);
   out->updateStrokeColorSpace(state);
@@ -1435,7 +1439,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
 
 void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   Object obj;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   GfxColor color;
   int i;
 
@@ -1450,10 +1454,11 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   state->setFillPattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
   if (obj.isNull()) {
-    colorSpace = new GfxDeviceRGBColorSpace();
-  } else {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceRGBColorSpace();
+  }
   obj.free();
   state->setFillColorSpace(colorSpace);
   out->updateFillColorSpace(state);
@@ -1473,17 +1478,18 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
 
 void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) {
   Object obj;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   GfxColor color;
   int i;
 
   state->setStrokePattern(NULL);
   res->lookupColorSpace("DefaultRGB", &obj);
-  if (obj.isNull()) {
-    colorSpace = new GfxDeviceRGBColorSpace();
-  } else {
+  if (!obj.isNull()) {
     colorSpace = GfxColorSpace::parse(&obj, this);
   }
+  if (colorSpace == NULL) {
+    colorSpace = new GfxDeviceRGBColorSpace();
+  }
   obj.free();
   state->setStrokeColorSpace(colorSpace);
   out->updateStrokeColorSpace(state);


More information about the poppler mailing list