bits: Print an error if someone tries to create an image with bpp < depth
authorSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 17 Jan 2010 21:45:23 +0000 (16:45 -0500)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 17 Jan 2010 21:47:15 +0000 (16:47 -0500)
Something in the X server apparently does this.

pixman/pixman-bits-image.c

index a3bcd69..23a3796 100644 (file)
@@ -1044,6 +1044,12 @@ pixman_image_create_bits (pixman_format_code_t format,
     return_val_if_fail (bits == NULL ||
                         (rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
 
+    if (PIXMAN_FORMAT_BPP (format) < PIXMAN_FORMAT_DEPTH (format))
+    {
+       fprintf (stderr, "Bad format passed to pixman_image_create_bits();\n");
+       return NULL;
+    }
+
     if (!bits && width && height)
     {
        free_me = bits = create_bits (format, width, height, &rowstride_bytes);