Fix possible out-of-bounds access when making distance fields

While extremely unlikely, there is a theoretical possibility that
the '0' glyph of a given font will have a width or height of 1 pixel,
in which case the (x + 1) / 2 way of getting the center would give us
an out of bounds pixel. We just default to true in this case, since
we cannot make any assumption based on the 0 glyph if it doesn't make
any sense. If the image is invalid, we default to false.

Change-Id: I36cea0b80c9d55aa10eb65db44d1b7ec8a40fc8c
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2016-03-04 13:15:03 +01:00
parent ea122fa9e3
commit 05ed495191

View File

@ -687,8 +687,10 @@ static void makeDistanceField(QDistanceFieldData *data, const QPainterPath &path
static bool imageHasNarrowOutlines(const QImage &im)
{
if (im.isNull())
if (im.isNull() || im.width() < 1 || im.height() < 1)
return false;
else if (im.width() == 1 || im.height() == 1)
return true;
int minHThick = 999;
int minVThick = 999;