From 42cf5f6f2c8c54b8d3beaf2e5795b34ea652e81d Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Sun, 17 Mar 2024 05:43:15 +0300 Subject: [PATCH] Workaround X11 configuration which return inconsistent settings Some X11 configurations, return inconsistent values for DefaultScreen and ScreenCount, which may result in access to memory beyound allocated value. An example of such configuration may be the proprietary nvidia driver in non-TwinView multiscreen mode (which is known a Zaphod Mode in OSS drivers) on the second display defaultScreen=1, but screenCount is only 1 as well. Signed-off-by: Alexander Golubev --- src/kernel/qdesktopwidget_x11.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/kernel/qdesktopwidget_x11.cpp b/src/kernel/qdesktopwidget_x11.cpp index 449af4ff..320b2ab0 100644 --- a/src/kernel/qdesktopwidget_x11.cpp +++ b/src/kernel/qdesktopwidget_x11.cpp @@ -138,6 +138,9 @@ void TQDesktopWidgetPrivate::init() { defaultScreen = DefaultScreen(TQPaintDevice::x11AppDisplay()); newScreenCount = ScreenCount(TQPaintDevice::x11AppDisplay()); + // Some configurations may return inconsistent data for this values + if ( defaultScreen < 0 || defaultScreen >= screenCount ) + defaultScreen = 0; use_xinerama = false; }