From 558f0a5ab4a88937b8c212c13309d11cb1a101af Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 8 Sep 2012 15:12:58 +0100 Subject: [PATCH] image: Check for an error surface before dereferencing the backend As the surface->backend will be NULL in such an error surface, and we may be legitimately doing boundary checks to reject the error surface. The alternative would be to set an explicit error surface backend. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54664 Signed-off-by: Chris Wilson --- src/cairo-image-surface-inline.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cairo-image-surface-inline.h b/src/cairo-image-surface-inline.h index 49591073f..743d5fd3e 100644 --- a/src/cairo-image-surface-inline.h +++ b/src/cairo-image-surface-inline.h @@ -73,7 +73,8 @@ _cairo_image_surface_is_clone (cairo_image_surface_t *image) static inline cairo_bool_t _cairo_surface_is_image (const cairo_surface_t *surface) { - return surface->backend->type == CAIRO_SURFACE_TYPE_IMAGE; + /* _cairo_surface_nil sets a NULL backend so be safe */ + return surface->backend && surface->backend->type == CAIRO_SURFACE_TYPE_IMAGE; } /**