From 27f7852b5ac8d137c917e653fb7113f419a4c77a Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Tue, 31 Aug 2010 00:30:54 -0400 Subject: [PATCH] When pixman_compute_composite_region32() returns FALSE, don't fini the region. The rule is that the region passed in must be initialized and that the region returned will still be valid. Ie., the lifecycle is the responsibility of the caller, regardless of what the function returns. Previously, compute_composite_region32() would finalize the region and then return FALSE, and then the caller would finalize the region again, leading to memory corruption in some cases. --- pixman/pixman.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/pixman/pixman.c b/pixman/pixman.c index 402c72c..62b58b8 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -302,17 +302,13 @@ pixman_compute_composite_region32 (pixman_region32_t * region, if (region->extents.x1 >= region->extents.x2 || region->extents.y1 >= region->extents.y2) { - pixman_region32_init (region); return FALSE; } if (dst_image->common.have_clip_region) { if (!clip_general_image (region, &dst_image->common.clip_region, 0, 0)) - { - pixman_region32_fini (region); return FALSE; - } } if (dst_image->common.alpha_map && dst_image->common.alpha_map->common.have_clip_region) @@ -321,7 +317,6 @@ pixman_compute_composite_region32 (pixman_region32_t * region, -dst_image->common.alpha_origin_x, -dst_image->common.alpha_origin_y)) { - pixman_region32_fini (region); return FALSE; } } @@ -330,10 +325,7 @@ pixman_compute_composite_region32 (pixman_region32_t * region, if (src_image->common.have_clip_region) { if (!clip_source_image (region, src_image, dest_x - src_x, dest_y - src_y)) - { - pixman_region32_fini (region); return FALSE; - } } if (src_image->common.alpha_map && src_image->common.alpha_map->common.have_clip_region) { @@ -341,7 +333,6 @@ pixman_compute_composite_region32 (pixman_region32_t * region, dest_x - (src_x - src_image->common.alpha_origin_x), dest_y - (src_y - src_image->common.alpha_origin_y))) { - pixman_region32_fini (region); return FALSE; } } @@ -349,17 +340,14 @@ pixman_compute_composite_region32 (pixman_region32_t * region, if (mask_image && mask_image->common.have_clip_region) { if (!clip_source_image (region, mask_image, dest_x - mask_x, dest_y - mask_y)) - { - pixman_region32_fini (region); return FALSE; - } + if (mask_image->common.alpha_map && mask_image->common.alpha_map->common.have_clip_region) { if (!clip_source_image (region, (pixman_image_t *)mask_image->common.alpha_map, dest_x - (mask_x - mask_image->common.alpha_origin_x), dest_y - (mask_y - mask_image->common.alpha_origin_y))) { - pixman_region32_fini (region); return FALSE; } } -- 2.7.4