pixman_image_t *image;
uint32_t *free_me = NULL;
- /* must be a whole number of uint32_t's
+ /* must be a whole number of uint32_t's
*/
return_val_if_fail (bits == NULL ||
- (rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
+ (rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
- if (!bits)
+ if (!bits && width && height)
{
free_me = bits = create_bits (format, width, height, &rowstride_bytes);
if (!bits)
return NULL;
}
-
+
image = allocate_image();
- if (!image)
+ if (!image) {
+ if (free_me)
+ free (free_me);
return NULL;
-
+ }
+
image->type = BITS;
image->bits.format = format;
image->bits.width = width;