summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowsfontengine.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-11-24 07:03:23 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2014-11-25 22:18:10 +0100
commit77f800bad71f093739ffdab7ac088194978deceb (patch)
treec7215e8c03aeb3007d742d802af2aa2aefc7b631 /src/plugins/platforms/windows/qwindowsfontengine.cpp
parent1992e206f65400c95611d2110035dc1c310b8ea2 (diff)
Fix potential access to uninitialized member
If GetTextMetrics() failed, there is no guarantee that TEXTMETRIC is initialized with any safe values. Change-Id: Idb5e3bc1bc2451368950978365487c908ce529e7 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsfontengine.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index d8ccb8cd56..38856a69de 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -289,14 +289,15 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name,
qCDebug(lcQpaFonts) << __FUNCTION__ << name << lf.lfHeight;
HDC hdc = m_fontEngineData->hdc;
SelectObject(hdc, hfont);
- fontDef.pixelSize = -lf.lfHeight;
const BOOL res = GetTextMetrics(hdc, &tm);
- fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
if (!res) {
qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__);
ZeroMemory(&tm, sizeof(TEXTMETRIC));
}
+ fontDef.pixelSize = -lf.lfHeight;
+ fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
+
cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000;
getCMap();