From 7c1078b830ac7b88a56dd2afa5dc48234e3b6e84 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 6 Aug 2008 09:23:18 +0100 Subject: [PATCH] Check return from pixman_image_set_filter(). Adding warn_unused_result to pixman detected a couple of instances where we abused the knowledge that the code currently can not fail, but in deference to its independent existence we should be more cautious. --- src/cairo-image-surface.c | 18 ++++++++++++++---- src/cairo-pattern.c | 9 +++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index d25cb967f..806a76f16 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -792,8 +792,9 @@ _cairo_image_surface_set_matrix (cairo_image_surface_t *surface, return CAIRO_STATUS_SUCCESS; } -static void -_cairo_image_surface_set_filter (cairo_image_surface_t *surface, cairo_filter_t filter) +static cairo_status_t +_cairo_image_surface_set_filter (cairo_image_surface_t *surface, + cairo_filter_t filter) { pixman_filter_t pixman_filter; @@ -823,7 +824,14 @@ _cairo_image_surface_set_filter (cairo_image_surface_t *surface, cairo_filter_t pixman_filter = PIXMAN_FILTER_BEST; } - pixman_image_set_filter (surface->pixman_image, pixman_filter, NULL, 0); + if (! pixman_image_set_filter (surface->pixman_image, + pixman_filter, + NULL, 0)) + { + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + } + + return CAIRO_STATUS_SUCCESS; } static cairo_status_t @@ -851,7 +859,9 @@ _cairo_image_surface_set_attributes (cairo_image_surface_t *surface, break; } - _cairo_image_surface_set_filter (surface, attributes->filter); + status = _cairo_image_surface_set_filter (surface, attributes->filter); + if (status) + return status; return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index e861d8878..0c84a8e3a 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -1318,6 +1318,13 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern, } } + if (! pixman_image_set_filter (pixman_image, PIXMAN_FILTER_BILINEAR, + NULL, 0)) + { + pixman_image_unref (pixman_image); + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + } + image = (cairo_image_surface_t *) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); if (image->base.status) { @@ -1325,8 +1332,6 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern, return image->base.status; } - pixman_image_set_filter (pixman_image, PIXMAN_FILTER_BILINEAR, NULL, 0); - _cairo_matrix_to_pixman_matrix (&pattern->base.matrix, &pixman_transform); if (!pixman_image_set_transform (pixman_image, &pixman_transform)) { cairo_surface_destroy (&image->base);