summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Slupski <jslupski@juljas.net>2008-02-15 00:55:30 +0100
committerCarl Worth <cworth@cworth.org>2008-02-14 16:43:50 -0800
commite7fe79aafe0c0be7badbb659442c2f834fbea9f3 (patch)
tree0014d661f2f920d16b8696a1f837c5cfd926a714
parentefc03cfcfb14a135eb1d5a66969179917b3b28e2 (diff)
downloadcairo-e7fe79aafe0c0be7badbb659442c2f834fbea9f3.tar.gz
Fix for a memory leak in pixman.
Port of a 1.6 fix for a memory leak in pixman_region_init_rects/pixman_rect_alloc when the count of boxes is 0.
-rw-r--r--pixman/src/pixregion.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/pixman/src/pixregion.c b/pixman/src/pixregion.c
index 1ed3ad701..d6caf6c5b 100644
--- a/pixman/src/pixregion.c
+++ b/pixman/src/pixregion.c
@@ -355,6 +355,15 @@ pixman_region_init_rects(pixman_region16_t *region, pixman_box16_t *boxes, int c
}
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 PIXMAN_REGION_STATUS_SUCCESS;
+
if (!pixman_rect_alloc(region, count))
return PIXMAN_REGION_STATUS_FAILURE;