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>
This commit is contained in:
parent
3d0fa4d4fb
commit
3c59065d5c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user