* 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/ChangeLog b/ChangeLog
index 6d7ae8c..568580a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-02-02 Werner Lemberg <wl@gnu.org>
+
+ * 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 <david.turner@freetype.org>
* docs/docmaker.py: Improved the index sorting routine to place
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 3f51e2b..3759d99 100644
--- 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,15 +106,19 @@
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 );
}