[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Attached is a fix for a bug which caused access to freed memory in
grabber (causing random crashes for me when using the update command).
Going to apply to 4.1.x and 4.0.x.
--
Elias Pschernig
Index: tools/datedit.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/datedit.c,v
retrieving revision 1.33
diff -u -r1.33 datedit.c
--- tools/datedit.c 29 Nov 2003 08:32:35 -0000 1.33
+++ tools/datedit.c 18 Sep 2004 12:47:42 -0000
@@ -1532,16 +1532,22 @@
static DATAFILE_PROPERTY *clone_properties(DATAFILE_PROPERTY *prop)
{
DATAFILE_PROPERTY *clone, *iter;
- int size = 0;
+ int size = 0, i;
if (!prop)
return NULL;
- for (iter = prop; iter->type != DAT_END; iter++)
+ for (iter = prop; iter->type != DAT_END; iter++) {
size++;
+ }
clone = _al_malloc(sizeof(DATAFILE_PROPERTY)*(size+1));
- memcpy(clone, prop, sizeof(DATAFILE_PROPERTY)*(size+1));
+
+ for (i = 0; i <= size; i++) {
+ clone[i].type = prop[i].type;
+ if (prop[i].dat)
+ clone[i].dat = ustrdup(prop[i].dat);
+ }
return clone;
}