From 3c59065d5cb5f82f90ed2e830e10c5807deeaf2c Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 12 Sep 2017 16:18:58 +0200 Subject: qglxconvenience: Avoid null pointer dereference glXGetVisualFromFBConfig according to documentation can return NULL [1]. This may result in a crash when running Qt applications using ARGB windows with XLIB_SKIP_ARGB_VISUALS defined. Also guard QXlibScopedPointerDeleter against illegally calling XFree(nullptr). [1] https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXGetVisualFromFBConfig.xml Task-number: QTBUG-58910 Change-Id: Ie076a1e906ed632543bdab03ef365f699533a61a Reviewed-by: Gatis Paeglis --- src/platformsupport/glxconvenience/qglxconvenience.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/platformsupport/glxconvenience/qglxconvenience.cpp') diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 8c26550c1e..74b7c63473 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -164,7 +164,8 @@ bool QXcbSoftwareOpenGLEnforcer::forceSoftwareOpenGL = false; template struct QXlibScopedPointerDeleter { static inline void cleanup(T *pointer) { - XFree(pointer); + if (pointer) + XFree(pointer); } }; @@ -202,6 +203,8 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format GLXFBConfig candidate = configs[i]; QXlibPointer visual(glXGetVisualFromFBConfig(display, candidate)); + if (visual.isNull()) + continue; const int actualRed = qPopulationCount(visual->red_mask); const int actualGreen = qPopulationCount(visual->green_mask); -- cgit v1.2.3