[PATCH] [cairo-image-surface] Use cairo_surface_status() guards.
Chris Wilson
chris at chris-wilson.co.uk
Fri Feb 22 11:58:19 PST 2008
Ensure the public API sanity checks its inputs using
cairo_surface_status() in a similar method to the core objects.
---
src/cairo-image-surface.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index e22381e..19bc609 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -531,6 +531,9 @@ cairo_image_surface_get_data (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+ if (cairo_surface_status (surface))
+ return NULL;
+
if (! _cairo_surface_is_image (surface)) {
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return NULL;
@@ -554,9 +557,12 @@ cairo_image_surface_get_format (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+ if (cairo_surface_status (surface))
+ return (cairo_format_t) 0;
+
if (! _cairo_surface_is_image (surface)) {
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
- return 0;
+ return (cairo_format_t) 0;
}
assert (CAIRO_FORMAT_VALID (image_surface->format));
@@ -577,6 +583,9 @@ cairo_image_surface_get_width (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+ if (cairo_surface_status (surface))
+ return 0;
+
if (! _cairo_surface_is_image (surface)) {
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
@@ -599,6 +608,9 @@ cairo_image_surface_get_height (cairo_surface_t *surface)
{
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+ if (cairo_surface_status (surface))
+ return 0;
+
if (! _cairo_surface_is_image (surface)) {
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
@@ -624,9 +636,11 @@ slim_hidden_def (cairo_image_surface_get_height);
int
cairo_image_surface_get_stride (cairo_surface_t *surface)
{
-
cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+ if (cairo_surface_status (surface))
+ return 0;
+
if (! _cairo_surface_is_image (surface)) {
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
return 0;
@@ -1321,6 +1335,10 @@ _cairo_image_surface_clone (cairo_image_surface_t *surface,
cairo_t *cr;
double x, y;
+ status = cairo_surface_status (&surface->base);
+ if (status)
+ return (cairo_image_surface_t *) _cairo_surface_create_in_error (status);
+
clone = (cairo_image_surface_t *)
cairo_image_surface_create (format,
surface->width, surface->height);
--
1.5.3.8
--=-BzpsUfdHqkE+TbB0ojYn
Content-Disposition: attachment; filename=0057-cairo-font-face-Avoid-PLT-entries-for-cairo_font_f.patch
Content-Type: application/mbox; name=0057-cairo-font-face-Avoid-PLT-entries-for-cairo_font_f.patch
Content-Transfer-Encoding: 7bit
More information about the cairo
mailing list