Fix compiler warnings.

* src/cff/cffdrivr.c (cff_ps_get_font_extra): Avoid code that relies
on numeric overflow.
Add cast.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Fix variable
types, add cast.
This commit is contained in:
Werner Lemberg 2017-10-05 14:26:33 +02:00
parent 1df35d94c7
commit 2e58808d48
3 changed files with 18 additions and 9 deletions

View File

@ -1,3 +1,14 @@
2017-10-05 Werner Lemberg <wl@gnu.org>
Fix compiler warnings.
* src/cff/cffdrivr.c (cff_ps_get_font_extra): Avoid code that relies
on numeric overflow.
Add cast.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Fix variable
types, add cast.
2017-10-04 John Tytgat <John.Tytgat@esko.com> 2017-10-04 John Tytgat <John.Tytgat@esko.com>
[cff] Add support for `FSType'. [cff] Add support for `FSType'.

View File

@ -515,7 +515,7 @@
if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) ) if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) )
goto Fail; goto Fail;
font_extra->fs_type = 0u; font_extra->fs_type = 0U;
embedded_postscript = cff_index_get_sid_string( embedded_postscript = cff_index_get_sid_string(
cff, cff,
@ -542,17 +542,15 @@
{ {
if ( *s >= '0' && *s <= '9' ) if ( *s >= '0' && *s <= '9' )
{ {
FT_UShort prev_fs_type; if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 )
prev_fs_type = font_extra->fs_type;
font_extra->fs_type = 10 * font_extra->fs_type + *s - '0';
if ( font_extra->fs_type < prev_fs_type )
{ {
/* Overflow - ignore the FSType value. */ /* Overflow - ignore the FSType value. */
font_extra->fs_type = 0U; font_extra->fs_type = 0U;
break; break;
} }
font_extra->fs_type *= 10;
font_extra->fs_type += (FT_UShort)( *s - '0' );
} }
else if ( *s != ' ' && *s != '\n' && *s != '\r' ) else if ( *s != ' ' && *s != '\n' && *s != '\r' )
{ {

View File

@ -229,7 +229,7 @@
{ {
FT_Byte* line; FT_Byte* line;
FT_Byte* temp; FT_Byte* temp;
FT_Int i, j; FT_UInt i, j;
unsigned int height = bitmap->rows; unsigned int height = bitmap->rows;
unsigned int width = bitmap->width; unsigned int width = bitmap->width;
@ -270,7 +270,7 @@
for ( i = 0; i < height; i++ ) for ( i = 0; i < height; i++ )
{ {
line = bitmap->buffer + i * pitch; line = bitmap->buffer + i * (FT_ULong)pitch;
for ( j = 0; j < width; j++ ) for ( j = 0; j < width; j++ )
{ {
temp[3 * j ] = line[j]; temp[3 * j ] = line[j];