From 31b52779bad4122d101cdffdb03153baf6cd011e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 5 Oct 2007 12:55:13 +0100 Subject: [PATCH] [cairo-boilerplate-xlib] Cleanup fallback after creation failure. Cleanup the local resource if we fail to create the X window and surface for the xlib fallback test target. --- boilerplate/cairo-boilerplate-xlib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c index 781f8f9e2..28d1a2e24 100644 --- a/boilerplate/cairo-boilerplate-xlib.c +++ b/boilerplate/cairo-boilerplate-xlib.c @@ -254,6 +254,7 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char *name, xtc->dpy = dpy = XOpenDisplay (NULL); if (xtc->dpy == NULL) { CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0)); + free (xtc); return NULL; } @@ -266,6 +267,8 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char *name, if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen, width, height)) { CAIRO_BOILERPLATE_LOG ("Surface is larger than the Screen.\n"); + XCloseDisplay (dpy); + free (xtc); return NULL; } @@ -283,8 +286,10 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char *name, surface = cairo_xlib_surface_create (dpy, xtc->drawable, DefaultVisual (dpy, screen), width, height); - - cairo_boilerplate_xlib_surface_disable_render (surface); + if (cairo_surface_status (surface)) + _cairo_boilerplate_xlib_cleanup (xtc); + else + cairo_boilerplate_xlib_surface_disable_render (surface); return surface; }