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>bb10
parent
1992e206f6
commit
77f800bad7
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue