From: Søren Sandmann Pedersen Date: Sat, 16 Jun 2007 05:15:05 +0000 (-0400) Subject: Plug leak in the bits=NULL case for pixman_image_create_bits() X-Git-Tag: pixman-0.9.4~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e365aaf7f34d9257fc53e8f180a84fa243edcb2c;p=platform%2Fupstream%2Fpixman.git Plug leak in the bits=NULL case for pixman_image_create_bits() --- diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index c08e8fc..5420416 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -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 */ diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index c0e98c4..c0f25b9 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -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 */ };