From baa0f71ddff8497a0e14fce9e3c74db034f3036d Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Fri, 23 Apr 2021 13:48:34 -0400 Subject: [PATCH] [cid] s/FT_ALLOC/FT_QALLOC/ and clean up. * src/cid/cidgload.c (cid_load_glyph): Do not zero out the buffer. * src/cid/cidload.c (cid_face_open, cid_read_subrs): Ditto. --- ChangeLog | 7 +++++++ src/cid/cidgload.c | 16 +++++++--------- src/cid/cidload.c | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab351d3d2..60d5d84c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-04-23 Alexei Podtelezhnikov + + [cid] s/FT_ALLOC/FT_QALLOC/ and clean up. + + * src/cid/cidgload.c (cid_load_glyph): Do not zero out the buffer. + * src/cid/cidload.c (cid_face_open, cid_read_subrs): Ditto. + 2021-04-23 Alexei Podtelezhnikov [pfr] s/FT_ALLOC/FT_QALLOC/ for initialized buffers. diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 2c5c83467..4dd98346a 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -85,10 +85,10 @@ if ( glyph_data.length != 0 ) { glyph_length = (FT_ULong)( glyph_data.length - cid->fd_bytes ); - (void)FT_ALLOC( charstring, glyph_length ); - if ( !error ) - ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes, - glyph_length ); + + if ( !FT_QALLOC( charstring, glyph_length ) ) + FT_MEM_COPY( charstring, glyph_data.pointer + cid->fd_bytes, + glyph_length ); } inc->funcs->free_glyph_data( inc->object, &glyph_data ); @@ -130,11 +130,9 @@ } glyph_length = off2 - off1; - if ( glyph_length == 0 ) - goto Exit; - if ( FT_ALLOC( charstring, glyph_length ) ) - goto Exit; - if ( FT_STREAM_READ_AT( cid->data_offset + off1, + + if ( FT_QALLOC( charstring, glyph_length ) || + FT_STREAM_READ_AT( cid->data_offset + off1, charstring, glyph_length ) ) goto Exit; } diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 3669c7ef2..f898a0d30 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -590,7 +590,7 @@ data_len = offsets[num_subrs] - offsets[0]; if ( FT_NEW_ARRAY( subr->code, num_subrs + 1 ) || - FT_ALLOC( subr->code[0], data_len ) ) + FT_QALLOC( subr->code[0], data_len ) ) goto Fail; if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) || @@ -812,7 +812,7 @@ } /* we must convert the data section from hexadecimal to binary */ - if ( FT_ALLOC( face->binary_data, parser->binary_length ) || + if ( FT_QALLOC( face->binary_data, parser->binary_length ) || FT_SET_ERROR( cid_hex_to_binary( face->binary_data, parser->binary_length, parser->data_offset,