[xcb] check for render extension presence

Otherwise this may leads to an invalid memory access to r.

Fixes: Bug 18588 - XCB backend fails with missing render.
https://bugs.freedesktop.org/show_bug.cgi?id=18588

Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
(cherry picked from commit 834f1d7b70)
This commit is contained in:
Julien Danjou 2008-11-18 10:01:49 +01:00 committed by Chris Wilson
parent 6fed98c0d3
commit 97b5240bee
2 changed files with 7 additions and 2 deletions

View file

@ -16,6 +16,7 @@ Steve Chaplin <stevech1097@yahoo.com.au> Bug fixes for PNG reading
Tomasz Cholewo <cholewo@ieee-cis.org> Bug fixes Tomasz Cholewo <cholewo@ieee-cis.org> Bug fixes
Manu Cornet <manu@manucornet.net> SVG build fix Manu Cornet <manu@manucornet.net> SVG build fix
Frederic Crozat <fcrozat@mandriva.com> Fix test suite for OPD platforms (IA64 or PPC64) Frederic Crozat <fcrozat@mandriva.com> Fix test suite for OPD platforms (IA64 or PPC64)
Julien Danjou <julien@danjou.info> XCB fixes
Radek Doulík <rodo@novell.com> Bug report and test case Radek Doulík <rodo@novell.com> Bug report and test case
John Ehresman <jpe@wingide.com> Build fixes for win32 John Ehresman <jpe@wingide.com> Build fixes for win32
John Ellson <ellson@research.att.com> First font/glyph extents functions John Ellson <ellson@research.att.com> First font/glyph extents functions

View file

@ -1732,7 +1732,8 @@ _cairo_xcb_surface_create_internal (xcb_connection_t *dpy,
int depth) int depth)
{ {
cairo_xcb_surface_t *surface; cairo_xcb_surface_t *surface;
const xcb_render_query_version_reply_t *r; const xcb_query_extension_reply_t *er;
const xcb_render_query_version_reply_t *r = NULL;
surface = malloc (sizeof (cairo_xcb_surface_t)); surface = malloc (sizeof (cairo_xcb_surface_t));
if (surface == NULL) if (surface == NULL)
@ -1764,7 +1765,10 @@ _cairo_xcb_surface_create_internal (xcb_connection_t *dpy,
; ;
} }
r = xcb_render_util_query_version(dpy); er = xcb_get_extension_data(dpy, &xcb_render_id);
if(er && er->present) {
r = xcb_render_util_query_version(dpy);
}
if (r) { if (r) {
surface->render_major = r->major_version; surface->render_major = r->major_version;
surface->render_minor = r->minor_version; surface->render_minor = r->minor_version;