shithub: freetype+ttf2subf

Download patch

ref: e56b411f32b8e3352b9d4c70a7fc3a5ea89ac359
parent: 65d328ead72f934c98243a0da5cfd70b9424e5bf
author: Werner Lemberg <[email protected]>
date: Fri Feb 2 23:34:53 EST 2001

* src/psaux/psobjs.c (shift_elements): Remove if clause (which is
obsolete now).

(reallocate_t1_table, PS_Table_Done): Replace REALLOC() with ALLOC()
+ MEM_Copy() to avoid a memory bug.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-02-02  Werner Lemberg  <[email protected]>
+
+	* src/psaux/psobjs.c (shift_elements): Remove if clause (which is
+	obsolete now).
+
+	(reallocate_t1_table, PS_Table_Done): Replace REALLOC() with ALLOC()
+	+ MEM_Copy() to avoid a memory bug.
+
 2001-02-01  David Turner  <[email protected]>
 
 	* docs/docmaker.py: Improved the index sorting routine to place
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auxiliary functions for PostScript fonts (body).                     */
 /*                                                                         */
-/*  Copyright 1996-2000 by                                                 */
+/*  Copyright 1996-2001 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -89,12 +89,11 @@
     FT_Byte**  limit  = offset + table->max_elems;
 
 
-    if ( delta )
-      for ( ; offset < limit; offset++ )
-      {
-        if ( offset[0] )
-          offset[0] += delta;
-      }
+    for ( ; offset < limit; offset++ )
+    {
+      if ( offset[0] )
+        offset[0] += delta;
+    }
   }
 
 
@@ -107,16 +106,20 @@
     FT_Error   error;
 
 
-    /* reallocate the base block */
-    if ( REALLOC( table->block, table->capacity, new_size ) )
+    /* allocate new base block */
+    if ( ALLOC( table->block, new_size ) )
       return error;
 
-    table->capacity = new_size;
-
-    /* shift all offsets if necessary */
-    if ( old_base )
+    /* copy elements and shift offsets */
+    if (old_base )
+    {
+      MEM_Copy( table->block, old_base, table->capacity );
       shift_elements( table, old_base );
+      FREE( old_base );
+    }
 
+    table->capacity = new_size;
+
     return FT_Err_Ok;
   }
 
@@ -200,20 +203,20 @@
   {
     FT_Memory  memory = table->memory;
     FT_Error   error;
-    FT_Byte*   old_base;
+    FT_Byte*   old_base = table->block;
 
 
     /* should never fail, because rec.cursor <= rec.size */
-    old_base = table->block;
     if ( !old_base )
       return;
 
-    if ( REALLOC( table->block, table->capacity, table->cursor ) )
+    if ( ALLOC( table->block, table->cursor ) )
       return;
-    table->capacity = table->cursor;
+    MEM_Copy( table->block, old_base, table->cursor );
+    shift_elements( table, old_base );
 
-    if ( old_base != table->block )
-      shift_elements( table, old_base );
+    table->capacity = table->cursor;
+    FREE( old_base );
   }