freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 2e58808: Fix compiler warnings.


From: Werner LEMBERG
Subject: [freetype2] master 2e58808: Fix compiler warnings.
Date: Thu, 5 Oct 2017 08:26:48 -0400 (EDT)

branch: master
commit 2e58808d4850f2a2d4d126974bc7d6f83499ce90
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    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.
---
 ChangeLog             | 11 +++++++++++
 src/cff/cffdrivr.c    | 12 +++++-------
 src/smooth/ftsmooth.c |  4 ++--
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b30c3b9..1890cbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-10-05  Werner Lemberg  <address@hidden>
+
+       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  <address@hidden>
 
        [cff] Add support for `FSType'.
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index e761409..906d315 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -515,7 +515,7 @@
       if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) )
         goto Fail;
 
-      font_extra->fs_type = 0u;
+      font_extra->fs_type = 0U;
 
       embedded_postscript = cff_index_get_sid_string(
                               cff,
@@ -542,17 +542,15 @@
           {
             if ( *s >= '0' && *s <= '9' )
             {
-              FT_UShort  prev_fs_type;
-
-
-              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 )
+              if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 )
               {
                 /* Overflow - ignore the FSType value.  */
                 font_extra->fs_type = 0U;
                 break;
               }
+
+              font_extra->fs_type *= 10;
+              font_extra->fs_type += (FT_UShort)( *s - '0' );
             }
             else if ( *s != ' ' && *s != '\n' && *s != '\r' )
             {
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 938d295..8262746 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -229,7 +229,7 @@
     {
       FT_Byte*  line;
       FT_Byte*  temp;
-      FT_Int    i, j;
+      FT_UInt   i, j;
 
       unsigned int  height = bitmap->rows;
       unsigned int  width  = bitmap->width;
@@ -270,7 +270,7 @@
 
       for ( i = 0; i < height; i++ )
       {
-        line = bitmap->buffer + i * pitch;
+        line = bitmap->buffer + i * (FT_ULong)pitch;
         for ( j = 0; j < width; j++ )
         {
           temp[3 * j    ] = line[j];



reply via email to

[Prev in Thread] Current Thread [Next in Thread]