summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorVitaly Fanaskov <vitaly.fanaskov@qt.io>2019-10-25 14:47:15 +0200
committerVitaly Fanaskov <vitaly.fanaskov@qt.io>2019-11-07 09:07:16 +0100
commited20f3209804d865804f9eb14c3fcfb4b7941140 (patch)
treec4ec52698a9bacc6580ebd5ffb3e9ea6c73fe40b /src/gui
parent75f791419c54311e1ebf14a0c1651192ab0349f1 (diff)
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 <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp3
1 files changed, 2 insertions, 1 deletions
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;