summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2016-09-03 08:20:31 +0200
committerWerner Lemberg <wl@gnu.org>2016-09-03 08:20:31 +0200
commitb98dfda392542f770a10063af625ef295c7803db (patch)
tree416b9a8f7d2b75e52c3ff3aad38a4c6bb5a61978 /src
parentf0fa7a67bfc334775b030d95cac763eeb7247436 (diff)
downloadfreetype2-b98dfda392542f770a10063af625ef295c7803db.tar.gz
[base] Avoid negative bitmap stroke dimensions (#48985).
* src/base/ftobjs.c (FT_Open_Face): Check whether negation was actually successful. For example, this can fail for value -32768 if the type is `signed short'. If there are problems, disable the stroke.
Diffstat (limited to 'src')
-rw-r--r--src/base/ftobjs.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 7a78357e1..0c9e4090c 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2314,11 +2314,24 @@
if ( bsize->height < 0 )
- bsize->height = (FT_Short)-bsize->height;
+ bsize->height = -bsize->height;
if ( bsize->x_ppem < 0 )
- bsize->x_ppem = (FT_Short)-bsize->x_ppem;
+ bsize->x_ppem = -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
+
+ /* check whether negation actually has worked */
+ if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
+ {
+ FT_TRACE0(( "FT_Open_Face:"
+ " Invalid bitmap dimensions for stroke %d,"
+ " now disabled\n", i ));
+ bsize->width = 0;
+ bsize->height = 0;
+ bsize->size = 0;
+ bsize->x_ppem = 0;
+ bsize->y_ppem = 0;
+ }
}
}