summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-02-12 14:08:32 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2010-02-12 14:08:32 +0000
commit37dbf157f354234d04cd4f0c5d069ff0d535e862 (patch)
tree6ec294ec72f7a7370177eaf066bf5eeedaee157d
parent6995e1d982a3ad84a1b74730ce557840745fcd8e (diff)
clip: Avoiding derefencing NULL clip_region
-rw-r--r--src/cairo-image-surface.c26
-rw-r--r--src/cairo-xcb-surface-render.c26
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);