From 50f3e9c41c6de98f917a9ddc78aabdda421f920a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 26 Jul 2015 18:22:16 +0100 Subject: sna: Add a small pixmap sanity check Signed-off-by: Chris Wilson --- src/sna/sna.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/sna/sna.h') diff --git a/src/sna/sna.h b/src/sna/sna.h index d8dc4122..5b3569e2 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -181,18 +181,29 @@ static inline WindowPtr get_root_window(ScreenPtr screen) #endif } +#if !NDEBUG +static PixmapPtr check_pixmap(PixmapPtr pixmap) +{ + assert(pixmap->refcnt >= 1); + assert(pixmap->devKind != 0xdeadbeef); + return pixmap; +} +#else +#define check_pixmap(p) p +#endif + static inline PixmapPtr get_window_pixmap(WindowPtr window) { assert(window); assert(window->drawable.type != DRAWABLE_PIXMAP); - return fbGetWindowPixmap(window); + return check_pixmap(fbGetWindowPixmap(window)); } static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable) { assert(drawable); if (drawable->type == DRAWABLE_PIXMAP) - return (PixmapPtr)drawable; + return check_pixmap((PixmapPtr)drawable); else return get_window_pixmap((WindowPtr)drawable); } -- cgit v1.2.3