From 7100ef4566595f73b967231d0b877781d0911de5 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 10 Jul 2023 14:31:18 -0400 Subject: [PATCH] glxsw: check geometry of drawables on creation this mimics the dri codepath and allows early rejection of invalid drawables to avoid subsequent breakage cc: mesa-stable Reviewed-by: Adam Jackson Part-of: --- src/glx/drisw_glx.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 9b67a1a871f..7dd41eb8746 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -675,11 +675,22 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable, { struct drisw_drawable *pdp; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; + unsigned depth; struct drisw_screen *psc = (struct drisw_screen *) base; const __DRIswrastExtension *swrast = psc->swrast; const __DRIkopperExtension *kopper = psc->kopper; Display *dpy = psc->base.dpy; + xcb_connection_t *conn = XGetXCBConnection(dpy); + xcb_generic_error_t *error; + xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, xDrawable); + xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(conn, cookie, &error); + if (reply) + depth = reply->depth; + free(reply); + if (!reply || error) + return NULL; + pdp = calloc(1, sizeof(*pdp)); if (!pdp) return NULL; @@ -709,11 +720,6 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable, /* Otherwise, or if XGetVisualInfo failed, ask the server */ if (pdp->xDepth == 0) { - Window root; - int x, y; - unsigned uw, uh, bw, depth; - - XGetGeometry(dpy, xDrawable, &root, &x, &y, &uw, &uh, &bw, &depth); pdp->xDepth = depth; }