From 4c022338aa787c216c3afa217987e4125bd15b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 11 Mar 2015 16:42:10 +0100 Subject: Fix segfault when requesting root window and there are no screens This was easy to hit with KDE Plasma 5.2.1; KWindowSystem called QX11Info::appRootWindow() which in turn tried to dereference a nullptr returned from QXcbConnection::primaryScreen(). #0 QXcbConnection::rootWindow (this=) at qtgui-5.5.9999/src/plugins/platforms/xcb/qxcbconnection.cpp:1303 #1 0x00007fc26da096d7 in QXcbNativeInterface::rootWindow (this=this@entry=0x7fc27d1734d0) at qtgui-5.5.9999/work/qtgui-5.5.9999/src/plugins/platforms/xcb/qxcbnativeinterface.cpp:425 #2 0x00007fc26da0ab21 in QXcbNativeInterface::nativeResourceForIntegration (this=0x7fc27d1734d0, resourceString=...) at qtgui-5.5.9999/work/qtgui-5.5.9999/src/plugins/platforms/xcb/qxcbnativeinterface.cpp:223 #3 0x00007fc27c563148 in QX11Info::appRootWindow (screen=screen@entry=-1) at qtx11extras-5.5.9999/work/qtx11extras-5.5.9999/src/x11extras/qx11info_x11.cpp:158 #4 0x00007fc27a98c444 in NETEventFilter::nativeEventFilter (this=0x7fc27d425b60, ev=0x7fc264004ad0) at kwindowsystem-5.7.0/work/kwindowsystem-5.7.0/src/kwindowsystem_x11.cpp:192 #5 0x00007fc2795d0a8a in QAbstractEventDispatcher::filterNativeEvent (this=, eventType=..., message=message@entry=0x7fc264004ad0, result=result@entry=0x7ffc96ecf348) at qtcore-5.5.9999/work/qtcore-5.5.9999/src/corelib/kernel/qabstracteventdispatcher.cpp:460 #6 0x00007fc26d9ea941 in QXcbConnection::handleXcbEvent (this=this@entry=0x7fc27d173580, event=event@entry=0x7fc264004ad0) at qtgui-5.5.9999/src/plugins/platforms/xcb/qxcbconnection.cpp:971 Change-Id: I98a5d767cd7e143f00666f6fc78e9dc10893513d Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 81d8a9b72a..d106473daa 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1300,7 +1300,8 @@ xcb_timestamp_t QXcbConnection::getTimestamp() xcb_window_t QXcbConnection::rootWindow() { - return primaryScreen()->root(); + QXcbScreen *s = primaryScreen(); + return s ? s->root() : 0; } #ifdef XCB_USE_XLIB -- cgit v1.2.3