Consolidate bitmap presetting and size assessment.

* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Change return type.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Return the bitmap
size assessment.

* src/raster/ftrend1.c (ft_raster1_render): Use it to refuse the
rendering of enourmous or far-fetched outlines.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
This commit is contained in:
Alexei Podtelezhnikov 2018-08-30 23:28:30 -04:00
parent ca980b4cf1
commit 1dacbd893d
5 changed files with 30 additions and 13 deletions

View File

@ -1,3 +1,16 @@
2018-08-30 Alexei Podtelezhnikov <apodtele@gmail.com>
Consolidate bitmap presetting and size assessment.
* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Change return type.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Return the bitmap
size assessment.
* src/raster/ftrend1.c (ft_raster1_render): Use it to refuse the
rendering of enourmous or far-fetched outlines.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
2018-08-30 Alexei Podtelezhnikov <apodtele@gmail.com>
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Correct mono.

View File

@ -701,8 +701,9 @@ FT_BEGIN_HEADER
ft_glyphslot_free_bitmap( FT_GlyphSlot slot );
/* Preset bitmap metrics of an outline glyphslot prior to rendering. */
FT_BASE( void )
/* Preset bitmap metrics of an outline glyphslot prior to rendering */
/* and check if the truncated bbox is too large for rendering. */
FT_BASE( FT_Bool )
ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin );

View File

@ -343,7 +343,8 @@
/* overflow-resistant presetting of bitmap position and dimensions */
FT_BASE_DEF( void )
/* also checks if the size is too large for rendering */
FT_BASE_DEF( FT_Bool )
ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
@ -480,6 +481,16 @@
bitmap->width = (unsigned int)width;
bitmap->rows = (unsigned int)height;
bitmap->pitch = pitch;
if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF ||
pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF )
{
FT_TRACE3(( "ft_glyphslot_peset_bitmap: [%ld %ld %ld %ld]\n",
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
return 1;
}
return 0;
}

View File

@ -127,12 +127,8 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
ft_glyphslot_preset_bitmap( slot, mode, origin );
if ( bitmap->width > 0x7FFF || bitmap->rows > 0x7FFF )
if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) )
{
FT_ERROR(( "ft_raster1_render: glyph is too large: %u x %u\n",
bitmap->width, bitmap->rows ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}

View File

@ -145,12 +145,8 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
ft_glyphslot_preset_bitmap( slot, mode, origin );
if ( bitmap->width > 0x7FFF || bitmap->rows > 0x7FFF )
if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) )
{
FT_ERROR(( "ft_smooth_render_generic: glyph is too large: %u x %u\n",
bitmap->width, bitmap->rows ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}