diff options
author | Kai Uwe Broulik <kde@privat.broulik.de> | 2017-09-12 16:18:58 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-09-27 08:35:28 +0000 |
commit | 3c59065d5cb5f82f90ed2e830e10c5807deeaf2c (patch) | |
tree | b522fe0c7c6775fc78b9ee67b2c0871b1560bf95 /src | |
parent | 3d0fa4d4fb870450f6e77d7248db91984ddf8b50 (diff) |
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 <gatis.paeglis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/platformsupport/glxconvenience/qglxconvenience.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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 <class T> 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<XVisualInfo> visual(glXGetVisualFromFBConfig(display, candidate)); + if (visual.isNull()) + continue; const int actualRed = qPopulationCount(visual->red_mask); const int actualGreen = qPopulationCount(visual->green_mask); |