[truetype] Avoid some memory zeroing in variations.

* src/truetype/ttgxvar.c (ft_var_readpackeddeltas, ft_var_load_avar,
ft_var_load_item_variation_store, ft_var_load_gvar): Use FT_QNEW_ARRAY
if memory immediately initialized or discarded otherwise.
This commit is contained in:
Alexei Podtelezhnikov 2021-11-06 22:59:31 -04:00
parent fc55291b1c
commit cb9e7b7aac
1 changed files with 9 additions and 9 deletions

View File

@ -178,7 +178,7 @@
/* in the nested loops below we increase `i' twice; */ /* in the nested loops below we increase `i' twice; */
/* it is faster to simply allocate one more slot */ /* it is faster to simply allocate one more slot */
/* than to add another test within the loop */ /* than to add another test within the loop */
if ( FT_NEW_ARRAY( points, n + 1 ) ) if ( FT_QNEW_ARRAY( points, n + 1 ) )
return NULL; return NULL;
*point_cnt = n; *point_cnt = n;
@ -271,7 +271,7 @@
FT_UNUSED( error ); FT_UNUSED( error );
if ( FT_NEW_ARRAY( deltas, delta_cnt ) ) if ( FT_QNEW_ARRAY( deltas, delta_cnt ) )
return NULL; return NULL;
i = 0; i = 0;
@ -402,7 +402,7 @@
goto Exit; goto Exit;
} }
if ( FT_NEW_ARRAY( blend->avar_segment, axisCount ) ) if ( FT_QNEW_ARRAY( blend->avar_segment, axisCount ) )
goto Exit; goto Exit;
segment = &blend->avar_segment[0]; segment = &blend->avar_segment[0];
@ -411,8 +411,8 @@
FT_TRACE5(( " axis %d:\n", i )); FT_TRACE5(( " axis %d:\n", i ));
segment->pairCount = FT_GET_USHORT(); segment->pairCount = FT_GET_USHORT();
if ( (FT_ULong)segment->pairCount * 4 > table_len || if ( (FT_ULong)segment->pairCount * 4 > table_len ||
FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) ) FT_QNEW_ARRAY( segment->correspondence, segment->pairCount ) )
{ {
/* Failure. Free everything we have done so far. We must do */ /* Failure. Free everything we have done so far. We must do */
/* it right now since loading the `avar' table is optional. */ /* it right now since loading the `avar' table is optional. */
@ -492,7 +492,7 @@
/* make temporary copy of item variation data offsets; */ /* make temporary copy of item variation data offsets; */
/* we will parse region list first, then come back */ /* we will parse region list first, then come back */
if ( FT_NEW_ARRAY( dataOffsetArray, itemStore->dataCount ) ) if ( FT_QNEW_ARRAY( dataOffsetArray, itemStore->dataCount ) )
goto Exit; goto Exit;
for ( i = 0; i < itemStore->dataCount; i++ ) for ( i = 0; i < itemStore->dataCount; i++ )
@ -1594,7 +1594,7 @@
goto Exit; goto Exit;
/* offsets (one more offset than glyphs, to mark size of last) */ /* offsets (one more offset than glyphs, to mark size of last) */
if ( FT_NEW_ARRAY( blend->glyphoffsets, gvar_head.glyphCount + 1 ) ) if ( FT_QNEW_ARRAY( blend->glyphoffsets, gvar_head.glyphCount + 1 ) )
goto Fail2; goto Fail2;
if ( gvar_head.flags & 1 ) if ( gvar_head.flags & 1 )
@ -1673,8 +1673,8 @@
goto Fail; goto Fail;
} }
if ( FT_NEW_ARRAY( blend->tuplecoords, if ( FT_QNEW_ARRAY( blend->tuplecoords,
gvar_head.axisCount * gvar_head.globalCoordCount ) ) gvar_head.axisCount * gvar_head.globalCoordCount ) )
goto Fail2; goto Fail2;
for ( i = 0; i < gvar_head.globalCoordCount; i++ ) for ( i = 0; i < gvar_head.globalCoordCount; i++ )