From dc7c047d1c68f343b66e81d9e79084e4171e2634 Mon Sep 17 00:00:00 2001 From: Vladimir Vukicevic Date: Mon, 10 Sep 2007 15:20:44 -0700 Subject: [PATCH] [memlk] don't try to allocate new data for 0-rectangle regions --- pixman/pixman-region.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c index fff49e7..ac23806 100644 --- a/pixman/pixman-region.c +++ b/pixman/pixman-region.c @@ -2518,6 +2518,8 @@ pixman_region_init_rects (pixman_region16_t *region, { int overlap; + /* if it's 1, then we just want to set the extents, so call + * the existing method. */ if (count == 1) { pixman_region_init_rect(region, boxes[0].x1, @@ -2528,6 +2530,15 @@ pixman_region_init_rects (pixman_region16_t *region, } pixman_region_init(region); + + /* if it's 0, don't call pixman_rect_alloc -- 0 rectangles is + * a special case, and causing pixman_rect_alloc would cause + * us to leak memory (because the 0-rect case should be the + * static pixman_region_emptyData data). + */ + if (count == 0) + return TRUE; + if (!pixman_rect_alloc(region, count)) return FALSE; -- 2.7.4