Xlib: Fix boilerplate to work with xlib-xcb

Xlib boilerplate includes cairo-xlib-surface-private.h, so that it can cast the
xlib cairo_surface_t to cairo_xlib_surface_t and then mess with some internals
of that struct.

However, xlib-xcb doesn't use that struct and thus this results in random memory
corruption. "Luckily", all the fields that this messes with don't corrupt any
fields in cairo_xlib_xcb_surface_t, but instead this writes past the end of the
buffer that was returned from malloc.

This commit just adds an #if to disable this code section since I have no idea
what a proper fix would be. This means that the xlib-fallback backend doesn't
actually test any fallbacks with xlib-xcb, however it never did so anyway.

If you have any idea how to fix xlib-fallback with xlib-xcb, please speak up.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2011-07-03 13:13:37 +02:00
parent eea31cc4ee
commit b6c972897b

View file

@ -412,6 +412,11 @@ _cairo_boilerplate_xlib_window_create_surface (const char *name,
cairo_status_t
cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface)
{
/* The following stunt doesn't work with xlib-xcb because it doesn't use
* cairo_xlib_surface_t for its surfaces. Sadly, there is no sane
* alternative, so we can't disable render with xlib-xcb.
* FIXME: Find an alternative. */
#if !CAIRO_HAS_XLIB_XCB_FUNCTIONS
cairo_xlib_surface_t *surface = (cairo_xlib_surface_t*) abstract_surface;
if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_XLIB)
@ -433,6 +438,7 @@ cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface
#endif
#if CAIRO_XLIB_SURFACE_HAS_BUGGY_REPEAT
surface->buggy_repeat = TRUE;
#endif
#endif
return CAIRO_STATUS_SUCCESS;