[poppler] 2 commits - poppler/CairoOutputDev.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Apr 18 08:58:49 PDT 2010


 poppler/CairoOutputDev.cc |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit 12d83931ae1b899b70c7ea5c01f03f123b1bb9a8
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Apr 18 17:53:48 2010 +0200

    [cairo] Check pattern status after setting matrix when rendering images
    
    Fixes rendering of document attached to kde bug
    http://bugs.kde.org/show_bug.cgi?id=135417.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 96407d4..845bf9d 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1594,6 +1594,10 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   cairo_matrix_init_translate (&matrix, 0, height);
   cairo_matrix_scale (&matrix, width, -height);
   cairo_pattern_set_matrix (pattern, &matrix);
+  if (cairo_pattern_status (pattern)) {
+    cairo_pattern_destroy (pattern);
+    goto cleanup;
+  }
 
   if (state->getFillColorSpace()->getMode() == csPattern) {
     mask = cairo_pattern_reference (pattern);
@@ -1861,6 +1865,12 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
     cairo_matrix_init_translate (&matrix, 0, scaledHeight);
     cairo_matrix_scale (&matrix, scaledWidth, -scaledHeight);
     cairo_pattern_set_matrix (pattern, &matrix);
+    if (cairo_pattern_status (pattern)) {
+      cairo_pattern_destroy (pattern);
+      imgStr->close();
+      delete imgStr;
+      return;
+    }
 
     mask = cairo_pattern_reference (pattern);
   } else {
@@ -2016,10 +2026,20 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
   cairo_matrix_init_translate (&matrix, 0, height);
   cairo_matrix_scale (&matrix, width, -height);
   cairo_pattern_set_matrix (pattern, &matrix);
+  if (cairo_pattern_status (pattern)) {
+    cairo_pattern_destroy (pattern);
+    cairo_pattern_destroy (maskPattern);
+    goto cleanup;
+  }
 
   cairo_matrix_init_translate (&maskMatrix, 0, maskHeight);
   cairo_matrix_scale (&maskMatrix, maskWidth, -maskHeight);
   cairo_pattern_set_matrix (maskPattern, &maskMatrix);
+  if (cairo_pattern_status (maskPattern)) {
+    cairo_pattern_destroy (maskPattern);
+    cairo_pattern_destroy (pattern);
+    goto cleanup;
+  }
 
   if (!printing) {
     cairo_save (cairo);
@@ -2156,10 +2176,20 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
   cairo_matrix_init_translate (&matrix, 0, height);
   cairo_matrix_scale (&matrix, width, -height);
   cairo_pattern_set_matrix (pattern, &matrix);
+  if (cairo_pattern_status (pattern)) {
+    cairo_pattern_destroy (pattern);
+    cairo_pattern_destroy (maskPattern);
+    goto cleanup;
+  }
 
   cairo_matrix_init_translate (&maskMatrix, 0, maskHeight);
   cairo_matrix_scale (&maskMatrix, maskWidth, -maskHeight);
   cairo_pattern_set_matrix (maskPattern, &maskMatrix);
+  if (cairo_pattern_status (maskPattern)) {
+    cairo_pattern_destroy (maskPattern);
+    cairo_pattern_destroy (pattern);
+    goto cleanup;
+  }
 
   if (fill_opacity != 1.0)
     cairo_push_group (cairo);
@@ -2379,6 +2409,10 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   cairo_matrix_init_translate (&matrix, 0, height);
   cairo_matrix_scale (&matrix, width, -height);
   cairo_pattern_set_matrix (pattern, &matrix);
+  if (cairo_pattern_status (pattern)) {
+    cairo_pattern_destroy (pattern);
+    goto cleanup;
+  }
 
   if (!mask && fill_opacity != 1.0) {
     maskPattern = cairo_pattern_create_rgba (1., 1., 1., fill_opacity);
commit ff6d501a2fc887fd49a985161f756d6d6b8e6c0d
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Apr 18 17:51:42 2010 +0200

    [cairo] Fix a crash when rendering 0x0 images
    
    See kde bug http://bugs.kde.org/show_bug.cgi?id=135417

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 49fb191..96407d4 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1465,6 +1465,9 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image,
 
   int orig_width = cairo_image_surface_get_width (image);
   int orig_height = cairo_image_surface_get_height (image);
+  if (orig_width == 0 || orig_height == 0)
+	  return CAIRO_FILTER_NEAREST;
+
   int scaled_width, scaled_height;
   getScaledSize (orig_width, orig_height, &scaled_width, &scaled_height);
 


More information about the poppler mailing list