From 37dbf157f354234d04cd4f0c5d069ff0d535e862 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 12 Feb 2010 14:08:32 +0000 Subject: clip: Avoiding derefencing NULL clip_region --- src/cairo-image-surface.c | 26 ++++++++++++++------------ src/cairo-xcb-surface-render.c | 26 ++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 76f50f7d..8dbf2e70 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -2025,9 +2025,6 @@ _clip_and_composite (cairo_image_surface_t *dst, cairo_bool_t need_clip_surface = FALSE; if (clip != NULL) { - cairo_rectangle_int_t rect; - cairo_bool_t is_empty; - status = _cairo_clip_get_region (clip, &clip_region); if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) return CAIRO_STATUS_SUCCESS; @@ -2035,17 +2032,22 @@ _clip_and_composite (cairo_image_surface_t *dst, assert (! _cairo_status_is_error (status)); need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED; - cairo_region_get_extents (clip_region, &rect); - is_empty = ! _cairo_rectangle_intersect (&extents->unbounded, &rect); - if (unlikely (is_empty)) - return CAIRO_STATUS_SUCCESS; + if (clip_region != NULL) { + cairo_rectangle_int_t rect; + cairo_bool_t is_empty; - is_empty = ! _cairo_rectangle_intersect (&extents->bounded, &rect); - if (unlikely (is_empty && extents->is_bounded)) - return CAIRO_STATUS_SUCCESS; + cairo_region_get_extents (clip_region, &rect); + is_empty = ! _cairo_rectangle_intersect (&extents->unbounded, &rect); + if (unlikely (is_empty)) + return CAIRO_STATUS_SUCCESS; - if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1) - clip_region = NULL; + is_empty = ! _cairo_rectangle_intersect (&extents->bounded, &rect); + if (unlikely (is_empty && extents->is_bounded)) + return CAIRO_STATUS_SUCCESS; + + if (cairo_region_num_rectangles (clip_region) == 1) + clip_region = NULL; + } } if (clip_region != NULL) { diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c index 9122d64b..5212caee 100644 --- a/src/cairo-xcb-surface-render.c +++ b/src/cairo-xcb-surface-render.c @@ -2352,9 +2352,6 @@ _clip_and_composite (cairo_xcb_surface_t *dst, cairo_bool_t need_clip_surface = FALSE; if (clip != NULL) { - cairo_rectangle_int_t rect; - cairo_bool_t is_empty; - status = _cairo_clip_get_region (clip, &clip_region); if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) return CAIRO_STATUS_SUCCESS; @@ -2362,17 +2359,22 @@ _clip_and_composite (cairo_xcb_surface_t *dst, assert (! _cairo_status_is_error (status)); need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED; - cairo_region_get_extents (clip_region, &rect); - is_empty = ! _cairo_rectangle_intersect (&extents->unbounded, &rect); - if (unlikely (is_empty)) - return CAIRO_STATUS_SUCCESS; + if (clip_region != NULL) { + cairo_rectangle_int_t rect; + cairo_bool_t is_empty; - is_empty = ! _cairo_rectangle_intersect (&extents->bounded, &rect); - if (unlikely (is_empty && extents->is_bounded)) - return CAIRO_STATUS_SUCCESS; + cairo_region_get_extents (clip_region, &rect); + is_empty = ! _cairo_rectangle_intersect (&extents->unbounded, &rect); + if (unlikely (is_empty)) + return CAIRO_STATUS_SUCCESS; - if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1) - clip_region = NULL; + is_empty = ! _cairo_rectangle_intersect (&extents->bounded, &rect); + if (unlikely (is_empty && extents->is_bounded)) + return CAIRO_STATUS_SUCCESS; + + if (cairo_region_num_rectangles (clip_region) == 1) + clip_region = NULL; + } } status = _cairo_xcb_connection_acquire (dst->connection); -- cgit v1.2.3