summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorJan Murawski <jan.murawski@governikus.de>2018-02-14 13:56:00 +0100
committerJan Murawski <jan.murawski@governikus.de>2018-02-16 13:57:05 +0000
commit5d3ce3a64090ccd3c38b235edf6228f41d003274 (patch)
treefd6cf711476ce55fbc454ad291c6d64674911d6d /src/plugins/platforms
parentf805be538205493b8e45e882fd013aaa13c05f3f (diff)
Handle unset $DISPLAY variable when using the offscreen platform
Skip the initialization of a QOffscreenX11GLXContext and thereby fix a null pointer dereference if the environment variable $DISPLAY is unset or contains invalid information. Task-number: QTBUG-66423 Change-Id: Ideea510d1c63a4f6700839955d833cd10e3b0bbe Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
index b46d94dfd3..93566220e8 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
@@ -71,6 +71,9 @@ QPlatformOpenGLContext *QOffscreenX11Integration::createPlatformOpenGLContext(QO
if (!m_connection)
m_connection.reset(new QOffscreenX11Connection);
+ if (!m_connection->display())
+ return nullptr;
+
return new QOffscreenX11GLXContext(m_connection->x11Info(), context);
}
@@ -81,12 +84,13 @@ QOffscreenX11Connection::QOffscreenX11Connection()
QByteArray displayName = qgetenv("DISPLAY");
Display *display = XOpenDisplay(displayName.constData());
m_display = display;
- m_screenNumber = DefaultScreen(display);
+ m_screenNumber = m_display ? DefaultScreen(m_display) : -1;
}
QOffscreenX11Connection::~QOffscreenX11Connection()
{
- XCloseDisplay((Display *)m_display);
+ if (m_display)
+ XCloseDisplay((Display *)m_display);
}
class QOffscreenX11Info