Don't complain if users try to read non-existing data from images
authorSøren Sandmann <sandmann@redhat.com>
Wed, 13 Jun 2007 03:37:25 +0000 (23:37 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Wed, 13 Jun 2007 03:37:25 +0000 (23:37 -0400)
pixman/pixman-image.c
pixman/pixman-trap.c

index 3fe8977..e47c7fc 100644 (file)
@@ -478,42 +478,46 @@ pixman_image_set_accessors (pixman_image_t             *image,
 uint32_t *
 pixman_image_get_data (pixman_image_t *image)
 {
-    return_val_if_fail (image->type == BITS, NULL);
+    if (image->type == BITS)
+       return image->bits.bits;
 
-    return image->bits.bits;
+    return NULL;
 }
 
 int
 pixman_image_get_width (pixman_image_t *image)
 {
-    return_val_if_fail (image->type == BITS, -1);
+    if (image->type == BITS)
+       return image->bits.width;
 
-    return image->bits.width;
-    
+    return 0;
 }
 
 int
 pixman_image_get_height (pixman_image_t *image)
 {
-    return_val_if_fail (image->type == BITS, -1);
+    if (image->type == BITS)
+       return image->bits.height;
 
-    return image->bits.height;
+    return 0;
 }
 
 int
 pixman_image_get_stride (pixman_image_t *image)
 {
-    return_val_if_fail (image->type == BITS, -1);
+    if (image->type == BITS)
+       return image->bits.rowstride * sizeof (uint32_t);
 
-    return sizeof (uint32_t) * image->bits.rowstride;
+    return 0;
 }
 
 int
 pixman_image_get_depth (pixman_image_t *image)
 {
-    return_val_if_fail (image->type == BITS, -1);
+    if (image->type == BITS)
+       return PIXMAN_FORMAT_DEPTH (image->bits.format);
 
-    return PIXMAN_FORMAT_DEPTH (image->bits.format);
+    return 0;
 }
 
 pixman_bool_t
index 179bf8f..31f08d8 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <config.h>
+#include <stdio.h>
 #include "pixman-private.h"
 
 typedef uint32_t FbBits;
@@ -119,6 +120,8 @@ pixman_rasterize_trapezoid (pixman_image_t *    image,
     pixman_fixed_t     y_off_fixed;
     pixman_edge_t      l, r;
     pixman_fixed_t     t, b;
+
+    return_if_fail (image->type == BITS);
     
     if (!pixman_trapezoid_valid (trap))
        return;