From ed20f3209804d865804f9eb14c3fcfb4b7941140 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Fri, 25 Oct 2019 14:47:15 +0200 Subject: QHighDpiScaling: fix potential null pointer dereference It's not guaranteed that QPlatformScreen::screen should always return a valid pointer. Furthermore, you can run into this situation with, for example, two screens setup. Task-number: QTBUG-53022 Change-Id: Ic23bb2c30b1245f98a793a44cc5e0b39f9afac4b Reviewed-by: Friedemann Kleint --- src/gui/kernel/qhighdpiscaling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 76548d5d86..704dcee633 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -657,7 +657,8 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen) // Check if there is a factor set on the screen object or associated // with the screen name. These are mutually exclusive, so checking // order is not significant. - QVariant byIndex = screen->screen()->property(scaleFactorProperty); + auto qScreen = screen->screen(); + auto byIndex = qScreen ? qScreen->property(scaleFactorProperty) : QVariant(); auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name()); if (byIndex.isValid()) { screenPropertyUsed = true; -- cgit v1.2.3