[cairo-commit] Branch '1.8' - src/cairo-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Aug 5 07:18:43 PDT 2009


 src/cairo-surface.c |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 06c2a4d2341dcfbed514bc6e21f051b4f41b3c59
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Aug 5 15:11:00 2009 +0100

    [surface] Protect against the user setting a fallback resolution of 0.
    
    Bug 23067 -- using clear drawing operator crashes printing
    http://bugs.freedesktop.org/show_bug.cgi?id=23067
    
    Here we were hitting an assert within the paginated surface after creating
    a zero sized fallback image, due to the paginated surface being created
    with an x fallback resolution of 0 dpi (by
    _gtk_printer_create_cairo_surface(), gtk/gtkprinter.c:924).
    
    Avoid the bug by guarding against bad input to
    cairo_surface_set_fallback_resolution() which also allows us to identity
    the invalid caller.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 609a0e0..c4abf83 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -934,6 +934,14 @@ cairo_surface_set_fallback_resolution (cairo_surface_t	*surface,
 	return;
     }
 
+    if (x_pixels_per_inch <= 0 || y_pixels_per_inch <= 0) {
+	/* XXX Could delay raising the error until we fallback, but throwing
+	 * the error here means that we can catch the real culprit.
+	 */
+	status = _cairo_surface_set_error (surface, CAIRO_STATUS_INVALID_MATRIX);
+	return;
+    }
+
     surface->x_fallback_resolution = x_pixels_per_inch;
     surface->y_fallback_resolution = y_pixels_per_inch;
 }


More information about the cairo-commit mailing list