summaryrefslogtreecommitdiff
path: root/src/gui/text/qfontengine_win.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-26 14:59:51 +0200
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-26 15:02:36 +0200
commiteb39ecce531f67b4f8b791f76796ab9010c9e745 (patch)
treed015a90570482b3ecd5103b28b79b00ac02c883a /src/gui/text/qfontengine_win.cpp
parentb69a8a9f6a88f6da971fd18641cfac26cc1035f5 (diff)
downloadqt4-tools-eb39ecce531f67b4f8b791f76796ab9010c9e745.tar.gz
Avoid undefined text metrics when GetTextMetrics() in QFontEngineWin
If GetTextMetrics() should fail, the results are undefined. When the undefined data are used, e.g. when painting text, this can cause a crash. To avoid the crash and make it clear that the metrics cannot be retrieved, we zero out the entire structure. Task-number: 251172 Reviewed-by: gunnar
Diffstat (limited to 'src/gui/text/qfontengine_win.cpp')
-rw-r--r--src/gui/text/qfontengine_win.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 173b822616..7a9d958dde 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -327,8 +327,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont
BOOL res = GetTextMetrics(hdc, &tm);
fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
- if (!res)
+ if (!res) {
qErrnoWarning("QFontEngineWin: GetTextMetrics failed");
+ ZeroMemory(&tm, sizeof(TEXTMETRIC));
+ }
cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000;
getCMap();