diff --git a/src/cairo-surface.c b/src/cairo-surface.c index f656ed5f0..8c8b8677c 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1218,6 +1218,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; + } + _cairo_surface_begin_modification (surface); surface->x_fallback_resolution = x_pixels_per_inch;