[Mesa-dev] [PATCH] glx: Add checks for context being direct before calling GetGLXDRIDrawable
Danylo Piliaiev
danylo.piliaiev at gmail.com
Wed Aug 1 14:15:17 UTC 2018
If indirect context is explicitly created by application and not
with LIBGL_ALWAYS_INDIRECT=1 then dri may be initialized in
__glXInitialize which allows Mesa to take invalid code paths
due to GetGLXDRIDrawable returning non-null value.
In most such places there are already checks for context being
direct before calling GetGLXDRIDrawable. This patch adds checks
where they were missed.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42699
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
---
src/glx/glx_pbuffer.c | 12 ++++++++++--
src/glx/glxcmds.c | 3 +++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index fd3327f120..6ee2ed58d2 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -133,6 +133,10 @@ ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
SyncHandle();
#ifdef GLX_DIRECT_RENDERING
+ struct glx_context *gc = __glXGetCurrentContext();
+ if (!gc->isDirect)
+ return;
+
pdraw = GetGLXDRIDrawable(dpy, drawable);
if (!pdraw)
@@ -286,7 +290,7 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
GLboolean use_glx_1_3;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- __GLXDRIdrawable *pdraw;
+ __GLXDRIdrawable *pdraw = NULL;
#endif
if (dpy == NULL)
@@ -316,7 +320,11 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
return 0;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- pdraw = GetGLXDRIDrawable(dpy, drawable);
+ struct glx_context *gc = __glXGetCurrentContext();
+
+ if (gc->isDirect) {
+ pdraw = GetGLXDRIDrawable(dpy, drawable);
+ }
if (attribute == GLX_BACK_BUFFER_AGE_EXT) {
struct glx_context *gc = __glXGetCurrentContext();
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 4db0228eab..3eb86b02a9 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -799,6 +799,8 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
DestroyGLXDrawable(dpy, glxpixmap);
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ struct glx_context *gc = __glXGetCurrentContext();
+ if (gc->isDirect)
{
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap);
@@ -831,6 +833,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
gc = __glXGetCurrentContext();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ if (gc->isDirect)
{
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
--
2.17.1
More information about the mesa-dev
mailing list