From 42192ad0fc7fe0fa7600f879646de867691351bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Tue, 12 Jun 2007 23:37:25 -0400 Subject: [PATCH] Don't complain if users try to read non-existing data from images --- pixman/pixman-image.c | 26 +++++++++++++++----------- pixman/pixman-trap.c | 3 +++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 3fe8977..e47c7fc 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -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 diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c index 179bf8f..31f08d8 100644 --- a/pixman/pixman-trap.c +++ b/pixman/pixman-trap.c @@ -23,6 +23,7 @@ */ #include +#include #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; -- 2.7.4