From 05ed49519120fa2cc4e00417efa0524ba00228a4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 4 Mar 2016 13:15:03 +0100 Subject: 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 --- src/gui/text/qdistancefield.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qdistancefield.cpp') diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 4d189786a1..6a7019bc3c 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -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; -- cgit v1.2.3