prevent a 16-bit integer overflow that would create problems when rendering *very* large anti-aliased outlines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/ChangeLog b/ChangeLog
index b5b2fdc..2ae2699 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-06-16 David Turner <david@freetype.org>
+
+ * src/smooth/ftgrays.c (gray_hline): prevent integer overflows
+ when rendering *very* large outlines
+
+
2006-06-16 Dmitry Timoshkov <dmitry@codeweavers.com>
* src/winfonts/winfnt.h: Add necessary structures for PE resource
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 15e7ab8..9e8ee5f 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -397,6 +397,8 @@
PCell *pcell, cell;
int x = ras.ex;
+ if (x > ras.max_ex)
+ x = ras.max_ex;
pcell = &ras.ycells[ras.ey];
for (;;)
@@ -462,6 +464,10 @@
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
+
+ if (ex > ras.max_ex)
+ ex = ras.max_ex;
+
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
@@ -492,6 +498,9 @@
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
+ if ( ex > ras.max_ex )
+ ex = (TCoord)( ras.max_ex );
+
if ( ex < ras.min_ex )
ex = (TCoord)( ras.min_ex - 1 );
@@ -1196,6 +1205,10 @@
y += (TCoord)ras.min_ey;
x += (TCoord)ras.min_ex;
+ /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
+ if (x >= 32768)
+ x = 32767;
+
if ( coverage )
{
/* see whether we can add this span to the current list */