When pixman_compute_composite_region32() returns FALSE, don't fini the region.
authorSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 31 Aug 2010 04:30:54 +0000 (00:30 -0400)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Wed, 8 Sep 2010 23:15:01 +0000 (19:15 -0400)
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

index 402c72c..62b58b8 100644 (file)
@@ -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;
            }
        }