From b7dff0d4e5fecbd4ed9a4cf08aeeb3e9b117ad0e Mon Sep 17 00:00:00 2001 From: Xiong Zhang Date: Mon, 2 Feb 2015 10:34:45 +0800 Subject: [PATCH] dri3_glx.c: Pass NULL DRI drawables into driver for None GLX drawables GLX_ARB_create_context spec says: If either or are not a valid GLX drawable, a GLXBadDrawable error is generated, unless and are both None and the OpenGL version supported by is 3.0 or greater. So when both and are None, it could pass NULL drawable into driver instead of returing GLXBadDrawable. https://bugs.freedesktop.org/show_bug.cgi?id=79629 Signed-off-by: Xiong Zhang --- src/glx/dri3_glx.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 1ddc723..9cd0aab 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -133,17 +133,24 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old, struct dri3_context *pcp = (struct dri3_context *) context; struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc; struct dri3_drawable *pdraw, *pread; + __DRIdrawable *dri_draw = NULL, *dri_read = NULL; pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw); pread = (struct dri3_drawable *) driFetchDrawable(context, read); driReleaseDrawables(&pcp->base); - if (pdraw == NULL || pread == NULL) + if ((pdraw == NULL && draw != None) || + (pread == NULL && read != None)) return GLXBadDrawable; - if (!(*psc->core->bindContext) (pcp->driContext, - pdraw->driDrawable, pread->driDrawable)) + if (pdraw) + dri_draw = pdraw->driDrawable; + + if (pread) + dri_read = pread->driDrawable; + + if (!(*psc->core->bindContext) (pcp->driContext, dri_draw, dri_read)) return GLXBadContext; return Success; -- 2.1.4