diff options
author | Uli Schlachter <psychon@znc.in> | 2011-07-01 18:53:18 +0200 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2011-07-01 18:53:18 +0200 |
commit | 26ee41435b864b266f6c2c06544d95f7cd125733 (patch) | |
tree | c489c77e8849576ed359b20723c618e64e75d352 | |
parent | 59fadcf7d93a179554a3f615c02e48547d6b141e (diff) |
xlib-xcb: Verify we really have an xcb surface
If the X11 server doesn't have the RENDER extension, the xcb backend falls back
to the image backend in some cases (e.g. create_similar). xlib-xcb didn't handle
this properly which means it used the result like a xcb surface.
Found while debugging https://bugs.freedesktop.org/show_bug.cgi?id=31931,
firefox died from a BadDrawable error when it tried to use the (bogous) result
from cairo_xlib_surface_get_drawable().
Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r-- | src/cairo-xlib-xcb-surface.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c index 16fabd87..b48cb929 100644 --- a/src/cairo-xlib-xcb-surface.c +++ b/src/cairo-xlib-xcb-surface.c @@ -485,6 +485,12 @@ cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface) _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); return 0; } + /* This can happen when e.g. create_similar falls back to an image surface + * because we don't have the RENDER extension. */ + if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) { + _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return 0; + } return surface->xcb->drawable; } @@ -524,6 +530,12 @@ cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface) _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); return 0; } + /* This can happen when e.g. create_similar falls back to an image surface + * because we don't have the RENDER extension. */ + if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) { + _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return 0; + } return surface->xcb->depth; } @@ -537,6 +549,12 @@ cairo_xlib_surface_get_width (cairo_surface_t *abstract_surface) _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); return 0; } + /* This can happen when e.g. create_similar falls back to an image surface + * because we don't have the RENDER extension. */ + if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) { + _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return 0; + } return surface->xcb->width; } @@ -550,6 +568,12 @@ cairo_xlib_surface_get_height (cairo_surface_t *abstract_surface) _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); return 0; } + /* This can happen when e.g. create_similar falls back to an image surface + * because we don't have the RENDER extension. */ + if (surface->xcb->base.type != CAIRO_SURFACE_TYPE_XCB) { + _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH); + return 0; + } return surface->xcb->height; } |