Commit 31f2dc19462774dd4e5b55f80cafcee07077e744

Werner Lemberg 2016-03-23T07:31:59

[raster, smooth] Directly test outline size (#47500). This improves stand-alone compilation. * src/base/ftoutln.c (FT_Outline_Render): Move cbox size test to... * src/raster/ftraster.c (ft_black_render), src/smooth/ftgrays.c (gray_raster_render): ...these functions.

diff --git a/ChangeLog b/ChangeLog
index 2a8c04b..ee6220b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2016-03-23  Werner Lemberg  <wl@gnu.org>
 
+	[raster, smooth] Directly test outline size (#47500).
+
+	This improves stand-alone compilation.
+
+	* src/base/ftoutln.c (FT_Outline_Render): Move cbox size test to...
+
+	* src/raster/ftraster.c (ft_black_render), src/smooth/ftgrays.c
+	(gray_raster_render): ...these functions.
+
+2016-03-23  Werner Lemberg  <wl@gnu.org>
+
 	[raster, smooth] Fix some clang sanitizer runtime issues.
 
 	* src/raster/ftraster.c (ft_black_reset, ft_black_set_mode,
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 1cf8644..fa2d2cf 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -618,7 +618,6 @@
     FT_Error     error;
     FT_Renderer  renderer;
     FT_ListNode  node;
-    FT_BBox      cbox;
 
 
     if ( !library )
@@ -630,11 +629,6 @@
     if ( !params )
       return FT_THROW( Invalid_Argument );
 
-    FT_Outline_Get_CBox( outline, &cbox );
-    if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
-         cbox.xMax >  0x1000000L || cbox.yMax >  0x1000000L )
-      return FT_THROW( Invalid_Outline );
-
     renderer = library->cur_renderer;
     node     = library->renderers.head;
 
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 2972553..01ed1c5 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -3175,6 +3175,20 @@
     if ( !target_map->buffer )
       return FT_THROW( Invalid );
 
+    /* reject too large outline coordinates */
+    {
+      FT_Vector*  vec   = outline->points;
+      FT_Vector*  limit = vec + outline->n_points;
+
+
+      for ( ; vec < limit; vec++ )
+      {
+        if ( vec->x < -0x1000000L || vec->x > 0x1000000L ||
+             vec->y < -0x1000000L || vec->y > 0x1000000L )
+         return FT_THROW( Invalid );
+      }
+    }
+
     ras.outline = *outline;
     ras.target  = *target_map;
 
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 2d548de..9b008a0 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -2074,6 +2074,20 @@ typedef ptrdiff_t  FT_PtrDist;
     if ( !( params->flags & FT_RASTER_FLAG_AA ) )
       return FT_THROW( Invalid_Mode );
 
+    /* reject too large outline coordinates */
+    {
+      FT_Vector*  vec   = outline->points;
+      FT_Vector*  limit = vec + outline->n_points;
+
+
+      for ( ; vec < limit; vec++ )
+      {
+        if ( vec->x < -0x1000000L || vec->x > 0x1000000L ||
+             vec->y < -0x1000000L || vec->y > 0x1000000L )
+         return FT_THROW( Invalid_Outline );
+      }
+    }
+
     /* compute clipping box */
     if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
     {