diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2016-03-04 13:15:03 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2016-03-31 12:53:26 +0000 |
commit | 05ed49519120fa2cc4e00417efa0524ba00228a4 (patch) | |
tree | 04da739a64ec57cb12329635cc129bf5d04db68e /src/gui/text/qdistancefield.cpp | |
parent | ea122fa9e30b78af6b7738284f33451741638444 (diff) |
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>
Diffstat (limited to 'src/gui/text/qdistancefield.cpp')
-rw-r--r-- | src/gui/text/qdistancefield.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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; |