From a2a2bd62ff37e2642f671ca7ebf26954e1856abe Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 6 May 2010 14:39:30 +0100 Subject: surface-fallback: Handle memfaults during clipping. Don't be lazy, propagate the error rather than asserting. --- src/cairo-surface-fallback.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/cairo-surface-fallback.c') diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index 5c01c4e76..25d03e62e 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -133,10 +133,11 @@ _create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern, if (clip != NULL) { status = _cairo_clip_get_region (clip, &clip_region); - assert (! _cairo_status_is_error (status)); - - /* The all-clipped state should never propagate this far. */ - assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO); + if (unlikely (_cairo_status_is_error (status) || + status == CAIRO_INT_STATUS_NOTHING_TO_DO)) + { + return status; + } clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED; } @@ -346,12 +347,13 @@ _clip_and_composite_source (cairo_clip_t *clip, if (clip != NULL) { status = _cairo_clip_get_region (clip, &clip_region); - assert (! _cairo_status_is_error (status)); - if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) - return CAIRO_STATUS_SUCCESS; + if (unlikely (_cairo_status_is_error (status) || + status == CAIRO_INT_STATUS_NOTHING_TO_DO)) + { + return status; + } } - /* Create a surface that is mask IN clip */ status = _create_composite_mask_pattern (&mask_pattern, clip, @@ -444,9 +446,11 @@ _clip_and_composite (cairo_clip_t *clip, if (clip != NULL) { status = _cairo_clip_get_region (clip, &clip_region); - assert (! _cairo_status_is_error (status)); - if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) - return CAIRO_STATUS_SUCCESS; + if (unlikely (_cairo_status_is_error (status) || + status == CAIRO_INT_STATUS_NOTHING_TO_DO)) + { + return status; + } clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED; } -- cgit v1.2.1