freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 6ada59a: [sfnt] s/FT_ALLOC/FT_QALLOC/ for initialized


From: Werner Lemberg
Subject: [freetype2] master 6ada59a: [sfnt] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
Date: Fri, 23 Apr 2021 19:23:41 -0400 (EDT)

branch: master
commit 6ada59ab7c28be3bd361823523766374939ce598
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    [sfnt] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
    
    * src/sfnt/sfdriver.c (get_win_string, get_apple_string,
    sfnt_get_var_ps_name): Do not zero out the buffer.
    * src/sfnt/sfobjs.c (sfnt_init_face): Ditto.
    * src/sfnt/sfwoff.c (woff_open_font): Ditto.
    * src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
---
 ChangeLog           | 10 ++++++++++
 src/sfnt/sfdriver.c | 15 ++++++++-------
 src/sfnt/sfobjs.c   |  4 ++--
 src/sfnt/sfwoff.c   |  4 ++--
 src/sfnt/sfwoff2.c  |  8 ++++----
 5 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 81a43a8..c5678ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-04-23  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
+       [sfnt] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
+
+       * src/sfnt/sfdriver.c (get_win_string, get_apple_string,
+       sfnt_get_var_ps_name): Do not zero out the buffer.
+       * src/sfnt/sfobjs.c (sfnt_init_face): Ditto.
+       * src/sfnt/sfwoff.c (woff_open_font): Ditto.
+       * src/sfnt/sfwoff2.c (woff2_open_font): Ditto.
+
+2021-04-23  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
        [cff,type1,type42] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
 
        * src/cff/cffload.c (cff_index_get_pointers, cff_index_get_name):
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index d02dc3d..824e709 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -501,7 +501,7 @@
     FT_UNUSED( error );
 
 
-    if ( FT_ALLOC( result, entry->stringLength / 2 + 1 ) )
+    if ( FT_QALLOC( result, entry->stringLength / 2 + 1 ) )
       return NULL;
 
     if ( FT_STREAM_SEEK( entry->stringOffset ) ||
@@ -560,7 +560,7 @@
     FT_UNUSED( error );
 
 
-    if ( FT_ALLOC( result, entry->stringLength + 1 ) )
+    if ( FT_QALLOC( result, entry->stringLength + 1 ) )
       return NULL;
 
     if ( FT_STREAM_SEEK( entry->stringOffset ) ||
@@ -928,8 +928,8 @@
 
         /* after the prefix we have character `-' followed by the   */
         /* subfamily name (using only characters a-z, A-Z, and 0-9) */
-        if ( FT_ALLOC( result, face->var_postscript_prefix_len +
-                               1 + ft_strlen( subfamily_name ) + 1 ) )
+        if ( FT_QALLOC( result, face->var_postscript_prefix_len +
+                                1 + ft_strlen( subfamily_name ) + 1 ) )
           return NULL;
 
         ft_strcpy( result, face->var_postscript_prefix );
@@ -957,9 +957,9 @@
     construct_instance_name:
       axis = mm_var->axis;
 
-      if ( FT_ALLOC( result,
-                     face->var_postscript_prefix_len +
-                       num_coords * MAX_VALUE_DESCRIPTOR_LEN + 1 ) )
+      if ( FT_QALLOC( result,
+                      face->var_postscript_prefix_len +
+                        num_coords * MAX_VALUE_DESCRIPTOR_LEN + 1 ) )
         return NULL;
 
       p = result;
@@ -993,6 +993,7 @@
         if ( t != ' ' && ft_isalnum( t ) )
           *p++ = t;
       }
+      *p++ = '\0';
     }
 
   check_length:
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 886d985..404c31d 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -643,8 +643,8 @@
        */
 
       if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) &&
-           !( FT_ALLOC( default_values, num_axes * 4 )  ||
-              FT_ALLOC( instance_values, num_axes * 4 ) )      )
+           !( FT_QALLOC( default_values, num_axes * 4 )  ||
+              FT_QALLOC( instance_values, num_axes * 4 ) )     )
       {
         /* the current stream position is 16 bytes after the table start */
         FT_ULong  array_start = FT_STREAM_POS() - 16 + offset;
diff --git a/src/sfnt/sfwoff.c b/src/sfnt/sfwoff.c
index 481179c..44c926e 100644
--- a/src/sfnt/sfwoff.c
+++ b/src/sfnt/sfwoff.c
@@ -160,8 +160,8 @@
     }
 
     /* Don't trust `totalSfntSize' before thorough checks. */
-    if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) ||
-         FT_NEW( sfnt_stream )                         )
+    if ( FT_QALLOC( sfnt, 12 + woff.num_tables * 16UL ) ||
+         FT_NEW( sfnt_stream )                          )
       goto Exit;
 
     sfnt_header = sfnt;
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
index 2edb15f..5a665b3 100644
--- a/src/sfnt/sfwoff2.c
+++ b/src/sfnt/sfwoff2.c
@@ -2174,8 +2174,8 @@
     }
 
     /* Write sfnt header. */
-    if ( FT_ALLOC( sfnt, sfnt_size ) ||
-         FT_NEW( sfnt_stream )       )
+    if ( FT_QALLOC( sfnt, sfnt_size ) ||
+         FT_NEW( sfnt_stream )        )
       goto Exit;
 
     sfnt_header = sfnt;
@@ -2246,8 +2246,8 @@
     }
 
     /* Allocate memory for uncompressed table data. */
-    if ( FT_ALLOC( uncompressed_buf, woff2.uncompressed_size ) ||
-         FT_FRAME_ENTER( woff2.totalCompressedSize )           )
+    if ( FT_QALLOC( uncompressed_buf, woff2.uncompressed_size ) ||
+         FT_FRAME_ENTER( woff2.totalCompressedSize )            )
       goto Exit;
 
     /* Uncompress the stream. */



reply via email to

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