* src/base/ftbitmap.c (FT_Bitmap_Blend): Use FT_ALLOC_MULT.

This call is fortified with builtin overflow checks.
This commit is contained in:
Alexei Podtelezhnikov 2026-02-20 23:48:14 -05:00
parent dd66971f3c
commit c111f0713c

View file

@ -922,14 +922,7 @@
target->pitch = (int)final_width * 4;
target->num_grays = 256;
if ( FT_LONG_MAX / target->pitch < (int)target->rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%u x %u)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) )
if ( FT_ALLOC_MULT( target->buffer, target->rows, target->pitch ) )
return error;
free_target_bitmap_on_error = 1;
@ -950,16 +943,9 @@
new_pitch = (int)final_width * 4;
if ( FT_LONG_MAX / new_pitch < (int)final_rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%u x %u)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
/* TODO: provide an in-buffer solution for large bitmaps */
/* to avoid allocation of a new buffer */
if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) )
if ( FT_ALLOC_MULT( buffer, final_rows, new_pitch ) )
goto Error;
/* copy data to new buffer */