shithub: freetype+ttf2subf

Download patch

ref: 6ada59ab7c28be3bd361823523766374939ce598
parent: ec9e5114b1fc878d8e26611ceacd7b2a2400a73c
author: Alexei Podtelezhnikov <[email protected]>
date: Fri Apr 23 15:22:51 EDT 2021

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-04-23  Alexei Podtelezhnikov  <[email protected]>
 
+	[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  <[email protected]>
+
 	[cff,type1,type42] s/FT_ALLOC/FT_QALLOC/ for initialized buffers.
 
 	* src/cff/cffload.c (cff_index_get_pointers, cff_index_get_name):
--- 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:
--- 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;
--- 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;
--- 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. */