mirror of
git://git.sv.nongnu.org/freetype/freetype2.git
synced 2026-01-19 04:52:09 +00:00
[base, smooth] Fortify direct rendering.
This is a better fix for #1384, which is rather about signed overflow. * include/freetype/ftimage.h (FT_Span): Use unsigned position. * src/smooth/ftgrays.c (gray_sweep_direct): Sync with FT_Span. * src/smooth/ftsmooth.c (ft_smooth_render): Remove redundant shift. * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Readjust limits.
This commit is contained in:
@@ -875,7 +875,7 @@ FT_BEGIN_HEADER
|
||||
*/
|
||||
typedef struct FT_Span_
|
||||
{
|
||||
short x;
|
||||
unsigned short x;
|
||||
unsigned short len;
|
||||
unsigned char coverage;
|
||||
|
||||
|
||||
@@ -526,27 +526,21 @@
|
||||
|
||||
/* Flag the bounding box size unsuitable for rendering. */
|
||||
/* FT_Renderer modules should check the return value. */
|
||||
/* The limit is based on the ppem value when available. */
|
||||
/* The limit is based on the ppem value when available. */
|
||||
{
|
||||
FT_Face face = slot->face;
|
||||
FT_Pos xlim = 0x7FFF;
|
||||
FT_Pos ylim = 0x7FFF;
|
||||
FT_Pos xlim = 0x8000;
|
||||
FT_Pos ylim = 0x8000;
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
|
||||
/* should fit 16-bit FT_Span after 3x implosion */
|
||||
if ( mode == FT_RENDER_MODE_LCD )
|
||||
xlim = 0x2AAA;
|
||||
#endif
|
||||
|
||||
if ( face )
|
||||
{
|
||||
xlim = FT_MIN( xlim, 10 * face->size->metrics.x_ppem );
|
||||
ylim = FT_MIN( ylim, 10 * face->size->metrics.y_ppem );
|
||||
}
|
||||
|
||||
if ( pbox.xMin < -xlim || pbox.xMax > xlim ||
|
||||
pbox.yMin < -ylim || pbox.yMax > ylim )
|
||||
if ( pbox.xMin < -xlim || pbox.xMax >= xlim ||
|
||||
pbox.yMin < -ylim || pbox.yMax >= ylim )
|
||||
{
|
||||
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
|
||||
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
|
||||
|
||||
@@ -1804,7 +1804,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||
FT_FILL_RULE( coverage, cover, fill );
|
||||
|
||||
span[n].coverage = (unsigned char)coverage;
|
||||
span[n].x = (short)x;
|
||||
span[n].x = (unsigned short)x;
|
||||
span[n].len = (unsigned short)( cell->x - x );
|
||||
|
||||
if ( ++n == FT_MAX_GRAY_SPANS )
|
||||
@@ -1823,7 +1823,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||
FT_FILL_RULE( coverage, area, fill );
|
||||
|
||||
span[n].coverage = (unsigned char)coverage;
|
||||
span[n].x = (short)cell->x;
|
||||
span[n].x = (unsigned short)cell->x;
|
||||
span[n].len = 1;
|
||||
|
||||
if ( ++n == FT_MAX_GRAY_SPANS )
|
||||
|
||||
@@ -494,12 +494,6 @@
|
||||
else
|
||||
y_shift += 64 * (FT_Int)bitmap->rows;
|
||||
|
||||
if ( origin )
|
||||
{
|
||||
x_shift += origin->x;
|
||||
y_shift += origin->y;
|
||||
}
|
||||
|
||||
/* translate outline to render it into the bitmap */
|
||||
if ( x_shift || y_shift )
|
||||
FT_Outline_Translate( outline, x_shift, y_shift );
|
||||
|
||||
Reference in New Issue
Block a user