[PATCH] Avoid a divide by zero crash.
mtewoodbury at gmail.com
mtewoodbury at gmail.com
Fri Feb 28 02:21:41 CST 2014
From: Max TenEyck Woodbury <max+git at mtew.isa-geek.net>
While tmHeight is not _supposed_ to ever be zero, it is an external
input and has been found to be zero in a few rare fonts. Detecting
and fixing THAT problem should be handled elsewhere. This change just
keeps the application from being blown away by a divide by zero
exception.
---
dlls/gdi32/freetype.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 5f4a570..122209f 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -7200,7 +7200,7 @@ static BOOL get_text_metrics(GdiFont *font, LPTEXTMETRICW ptm)
/* Make sure that the font has sane width/height ratio */
if (font->aveWidth)
{
- if ((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) / font->potm->otmTextMetrics.tmHeight > 100)
+ if ((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) > 100 * font->potm->otmTextMetrics.tmHeight)
{
WARN("Ignoring too large font->aveWidth %d\n", font->aveWidth);
font->aveWidth = 0;
--
1.8.0.rc0.18.gf84667d
More information about the wine-patches
mailing list