[poppler] poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sat Feb 26 03:18:27 PST 2011


 poppler/CairoOutputDev.cc |   28 ++++++++++++++++------------
 poppler/CairoOutputDev.h  |    2 +-
 2 files changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 22eb01d305ea2560d26417ca8df9c0465d4e9a82
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Feb 26 12:17:49 2011 +0100

    cairo: Fix a crash when rendering a document with inline images

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 7ffeb1f..35f2b45 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -2422,7 +2422,7 @@ GBool CairoOutputDev::getStreamData (Stream *str, char **buffer, int *length)
   return gTrue;
 }
 
-void CairoOutputDev::setMimeData(Stream *str, Ref ref, cairo_surface_t *image)
+void CairoOutputDev::setMimeData(Stream *str, Object *ref, cairo_surface_t *image)
 {
   char *strBuffer;
   int len;
@@ -2444,16 +2444,20 @@ void CairoOutputDev::setMimeData(Stream *str, Ref ref, cairo_surface_t *image)
     cairo_status_t st;
 
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
-    GooString *surfaceId = new GooString("poppler-surface-");
-    char *idBuffer = copyString(surfaceId->getCString());
-    surfaceId->appendf("{0:d}-{1:d}", ref.gen, ref.num);
-    st = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_UNIQUE_ID,
-                                      (const unsigned char *)idBuffer,
-                                      surfaceId->getLength(),
-                                      gfree, idBuffer);
-    if (st)
-      gfree(idBuffer);
-    delete surfaceId;
+    if (ref && ref->isRef()) {
+      Ref imgRef = ref->getRef();
+      GooString *surfaceId = new GooString("poppler-surface-");
+      char *idBuffer = copyString(surfaceId->getCString());
+
+      surfaceId->appendf("{0:d}-{1:d}", imgRef.gen, imgRef.num);
+      st = cairo_surface_set_mime_data (image, CAIRO_MIME_TYPE_UNIQUE_ID,
+                                        (const unsigned char *)idBuffer,
+                                        surfaceId->getLength(),
+                                        gfree, idBuffer);
+      if (st)
+        gfree(idBuffer);
+      delete surfaceId;
+    }
 #endif
 
     st = cairo_surface_set_mime_data (image,
@@ -2579,7 +2583,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
 
   cairo_surface_mark_dirty (image);
 
-  setMimeData(str, ref->getRef(), image);
+  setMimeData(str, ref, image);
 
   pattern = cairo_pattern_create_for_surface (image);
   cairo_surface_destroy (image);
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index fa22059..e6fde85 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -283,7 +283,7 @@ protected:
   cairo_filter_t getFilterForSurface(cairo_surface_t *image,
 				     GBool interpolate);
   GBool getStreamData (Stream *str, char **buffer, int *length);
-  void setMimeData(Stream *str, Ref ref, cairo_surface_t *image);
+  void setMimeData(Stream *str, Object *ref, cairo_surface_t *image);
   
   GfxRGB fill_color, stroke_color;
   cairo_pattern_t *fill_pattern, *stroke_pattern;


More information about the poppler mailing list