From 77f800bad71f093739ffdab7ac088194978deceb Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 24 Nov 2014 07:03:23 +0400 Subject: [PATCH] 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 --- src/plugins/platforms/windows/qwindowsfontengine.cpp | 5 +++-- 1 file 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();