Plug leak in the bits=NULL case for pixman_image_create_bits()
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 Jun 2007 05:15:05 +0000 (01:15 -0400)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sat, 16 Jun 2007 05:15:05 +0000 (01:15 -0400)
pixman/pixman-image.c
pixman/pixman-private.h

index c08e8fc..5420416 100644 (file)
@@ -135,6 +135,9 @@ pixman_image_unref (pixman_image_t *image)
 #if 0
        memset (image, 0xaa, sizeof (pixman_image_t));
 #endif
+
+       if (image->type == BITS && image->bits.free_me)
+           free (image->bits.free_me);
        
        free (image);
     }
@@ -304,6 +307,7 @@ pixman_image_create_bits (pixman_format_code_t  format,
                          int                   rowstride_bytes)
 {
     pixman_image_t *image;
+    uint32_t *free_me = NULL;
 
     /* must be a whole number of uint32_t's 
      */
@@ -312,7 +316,7 @@ pixman_image_create_bits (pixman_format_code_t  format,
 
     if (!bits)
     {
-       bits = create_bits (format, width, height, &rowstride_bytes);
+       free_me = bits = create_bits (format, width, height, &rowstride_bytes);
        if (!bits)
            return NULL;
     }
@@ -327,6 +331,8 @@ pixman_image_create_bits (pixman_format_code_t  format,
     image->bits.width = width;
     image->bits.height = height;
     image->bits.bits = bits;
+    image->bits.free_me = free_me;
+    
     image->bits.rowstride = rowstride_bytes / sizeof (uint32_t); /* we store it in number
                                                                  * of uint32_t's
                                                                  */
index c0e98c4..c0f25b9 100644 (file)
@@ -239,6 +239,7 @@ struct bits_image
     int                                width;
     int                                height;
     uint32_t *                 bits;
+    uint32_t *                 free_me;
     int                                rowstride; /* in number of uint32_t's */
 };