summaryrefslogtreecommitdiffstats
path: root/src/smooth/ftsmooth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/smooth/ftsmooth.c')
-rw-r--r--src/smooth/ftsmooth.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index a6db504..eed6353 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -17,10 +17,12 @@
#include <ft2build.h>
+#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftsmooth.h"
#include "ftgrays.h"
+#include "ftspic.h"
#include "ftsmerrs.h"
@@ -153,7 +155,7 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- /* allocate new one, depends on pixel format */
+ /* allocate new one */
pitch = width;
if ( hmul )
{
@@ -194,6 +196,19 @@
#endif
+#if FT_UINT_MAX > 0xFFFFU
+
+ /* Required check is ( pitch * height < FT_ULONG_MAX ), */
+ /* but we care realistic cases only. Always pitch <= width. */
+ if ( width > 0xFFFFU || height > 0xFFFFU )
+ {
+ FT_ERROR(( "ft_smooth_render_generic: glyph too large: %d x %d\n",
+ width, height ));
+ return Smooth_Err_Raster_Overflow;
+ }
+
+#endif
+
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
bitmap->width = width;
@@ -310,12 +325,19 @@
FT_Outline_Translate( outline, x_shift, y_shift );
+ /*
+ * XXX: on 16bit system, we return an error for huge bitmap
+ * to prevent an overflow.
+ */
+ if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
+ return Smooth_Err_Invalid_Pixel_Size;
+
if ( error )
goto Exit;
slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = x_left;
- slot->bitmap_top = y_top;
+ slot->bitmap_left = (FT_Int)x_left;
+ slot->bitmap_top = (FT_Int)y_top;
Exit:
if ( outline && origin )
@@ -376,10 +398,8 @@
}
- FT_CALLBACK_TABLE_DEF
- const FT_Renderer_Class ft_smooth_renderer_class =
- {
- {
+ FT_DEFINE_RENDERER(ft_smooth_renderer_class,
+
FT_MODULE_RENDERER,
sizeof( FT_RendererRec ),
@@ -392,7 +412,7 @@
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
- },
+ ,
FT_GLYPH_FORMAT_OUTLINE,
@@ -401,14 +421,12 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
- (FT_Raster_Funcs*) &ft_grays_raster
- };
+ (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
+ )
- FT_CALLBACK_TABLE_DEF
- const FT_Renderer_Class ft_smooth_lcd_renderer_class =
- {
- {
+ FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class,
+
FT_MODULE_RENDERER,
sizeof( FT_RendererRec ),
@@ -421,7 +439,7 @@
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
- },
+ ,
FT_GLYPH_FORMAT_OUTLINE,
@@ -430,15 +448,11 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
- (FT_Raster_Funcs*) &ft_grays_raster
- };
+ (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
+ )
+ FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class,
-
- FT_CALLBACK_TABLE_DEF
- const FT_Renderer_Class ft_smooth_lcdv_renderer_class =
- {
- {
FT_MODULE_RENDERER,
sizeof( FT_RendererRec ),
@@ -451,7 +465,7 @@
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
- },
+ ,
FT_GLYPH_FORMAT_OUTLINE,
@@ -460,8 +474,8 @@
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
- (FT_Raster_Funcs*) &ft_grays_raster
- };
+ (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
+ )
/* END */