[PATCH] Avoid a divide by zero crash.

Max Woodbury mtewoodbury at gmail.com
Sat Mar 1 02:57:51 CST 2014


[PATCH] Avoid a divide by zero crash.
 

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 > 99 * 
font->potm->otmTextMetrics.tmHeight + 1)
              {
                  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