diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2013-01-23 19:51:28 -0500 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2013-01-23 19:51:28 -0500 |
commit | e1a2ac1900f2f16ec48fb4840a6b7965a8373c2b (patch) | |
tree | 9ce3ac5c61f8887e8215ca007769ff55913f767d | |
parent | 869fb8c49ddf292d6daf4826172a308973d3e11f (diff) | |
download | freetype2-e1a2ac1900f2f16ec48fb4840a6b7965a8373c2b.tar.gz |
[base] Fix integer overflow.
* src/base/ftoutln.c (FT_Outline_Get_Orientation): Scale the
coordinates down to avoid overflow.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/base/ftoutln.c | 13 |
2 files changed, 19 insertions, 1 deletions
@@ -1,5 +1,12 @@ 2013-01-23 Alexei Podtelezhnikov <apodtele@gmail.com> + [base] Fix integer overflow. + + * src/base/ftoutln.c (FT_Outline_Get_Orientation): Scale the + coordinates down to avoid overflow. + +2013-01-23 Alexei Podtelezhnikov <apodtele@gmail.com> + [base] Split out MSB function. * src/base/fttrigon.c (ft_trig_prenorm): Borrow from here. diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 27aba015a..875968c6c 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -1009,6 +1009,8 @@ FT_EXPORT_DEF( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ) { + FT_BBox cbox; + FT_Int xshift, yshift; FT_Vector* points; FT_Vector v_prev, v_cur; FT_Int c, n, first; @@ -1023,6 +1025,14 @@ /* cubic or quadratic curves, this test deals with the polygon */ /* only which is spanned up by the control points. */ + FT_Outline_Get_CBox( outline, &cbox ); + + xshift = FT_MSB( FT_ABS( cbox.xMax ) | FT_ABS( cbox.xMin ) ) - 14; + xshift = FT_MAX( xshift, 0 ); + + yshift = FT_MSB( cbox.yMax - cbox.yMin ) - 14; + yshift = FT_MAX( yshift, 0 ); + points = outline->points; first = 0; @@ -1036,7 +1046,8 @@ for ( n = first; n <= last; n++ ) { v_cur = points[n]; - area += ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ); + area += ( ( v_cur.y - v_prev.y ) >> yshift ) * + ( ( v_cur.x + v_prev.x ) >> xshift ); v_prev = v_cur; } |