[PATCH] dlls/gdi32/fretype.c: Avoid division by zero.

Dmitry Timoshkov dmitry at baikal.ru
Sat May 4 00:56:26 CDT 2013


Max TenEyck Woodbury <max at mtew.isa-geek.net> wrote:

> >> +        if ( font->aveWidth && font->potm->otmTextMetrics.tmHeight ) {
> >> +            if (((font->aveWidth + font->potm->otmTextMetrics.tmHeight - 1) /
> >> +                 font->potm->otmTextMetrics.tmHeight) > 100) {
> >>                   WARN("Ignoring too large font->aveWidth %d\n", font->aveWidth);
> >>                   font->aveWidth = 0;
> >>               }
> >
> > In which case font->potm->otmTextMetrics.tmHeight is going to be 0?
> >
> I am not sure what you are asking.  I have had this particular division
> throw an exception for some font I have installed, but I have no idea
> which one at the moment.  So if you are implying that font->aveWidth==0
> is always true if font->potm->otmTextMetrics.tmHeight==0, that seems not
> to be the case.

If font->potm->otmTextMetrics.tmHeight is 0 then the font is invalid and
should not be loaded and used at all. There is no point is adding checks
for things that shouldn't happen, and may cause various bad things in other
places of code as well.

-- 
Dmitry.



More information about the wine-devel mailing list