[base] Don't zero out allocated memory twice (#51816).

Patch applied from bug report.

* src/base/ftutil.c (ft_mem_qrealloc): Use low-level allocation to
avoid unnecessary overhead.
This commit is contained in:
Werner Lemberg 2017-08-22 08:41:03 +02:00
parent 0aca17cf53
commit bd28952e23
2 changed files with 15 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2017-08-22 Werner Lemberg <wl@gnu.org>
[base] Don't zero out allocated memory twice (#51816).
Patch applied from bug report.
* src/base/ftutil.c (ft_mem_qrealloc): Use low-level allocation to
avoid unnecessary overhead.
2017-08-22 Werner Lemberg <wl@gnu.org>
[truetype] Integer overflow.

View File

@ -135,7 +135,7 @@
ft_mem_free( memory, block );
block = NULL;
}
else if ( new_count > FT_INT_MAX/item_size )
else if ( new_count > FT_INT_MAX / item_size )
{
error = FT_THROW( Array_Too_Large );
}
@ -143,13 +143,15 @@
{
FT_ASSERT( !block );
block = ft_mem_alloc( memory, new_count*item_size, &error );
block = memory->alloc( memory, new_count * item_size );
if ( block == NULL )
error = FT_THROW( Out_Of_Memory );
}
else
{
FT_Pointer block2;
FT_Long cur_size = cur_count*item_size;
FT_Long new_size = new_count*item_size;
FT_Long cur_size = cur_count * item_size;
FT_Long new_size = new_count * item_size;
block2 = memory->realloc( memory, cur_size, new_size, block );