summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-08-16 14:34:07 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-08-16 14:56:27 +0100
commit7d853bcabcc1c55b79a05280a0eb35828b93163d (patch)
tree4847085f4ebd86b6310d172f8b0f7a87ea850c24 /boilerplate
parentbc635da45a32eb9b7aff6fa5f7f560ebf99092a8 (diff)
[cairo-boilerplate-xlib] Check for NULL xrender_format before use.
Testing for XRender support (xrender_format != NULL) after dereferencing said format doesn't work as intended.
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/cairo-boilerplate-xlib.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index 615fc98fa..bfdc7d082 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -124,13 +124,24 @@ _cairo_boilerplate_xlib_perf_create_surface (Display *dpy,
switch (content) {
case CAIRO_CONTENT_COLOR_ALPHA:
xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ if (xrender_format == NULL) {
+ CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+ return NULL;
+ }
+
xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
width, height, xrender_format->depth);
xtc->drawable_is_pixmap = TRUE;
break;
+
case CAIRO_CONTENT_COLOR:
visual = DefaultVisual (dpy, DefaultScreen (dpy));
xrender_format = XRenderFindVisualFormat (dpy, visual);
+ if (xrender_format == NULL) {
+ CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+ return NULL;
+ }
+
attr.override_redirect = True;
xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
width, height, 0, xrender_format->depth,
@@ -138,15 +149,12 @@ _cairo_boilerplate_xlib_perf_create_surface (Display *dpy,
XMapWindow (dpy, xtc->drawable);
xtc->drawable_is_pixmap = FALSE;
break;
+
case CAIRO_CONTENT_ALPHA:
default:
CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
return NULL;
}
- if (xrender_format == NULL) {
- CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
- return NULL;
- }
return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
DefaultScreenOfDisplay (dpy),