changeset 1181:2f3397e53b05 trunk

[svn] - memory cleanups, purify-assisted.
author nenolod
date Sat, 09 Jun 2007 06:16:03 -0700
parents cc6df5de72a6
children 8df9aab3897e
files ChangeLog src/paranormal/libcalc/dict.c
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jun 09 06:10:17 2007 -0700
+++ b/ChangeLog	Sat Jun 09 06:16:03 2007 -0700
@@ -1,3 +1,11 @@
+2007-06-09 13:10:17 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [2554]
+  - fix invalid write of size 4 (actuators.c:56)
+  
+  trunk/src/paranormal/actuators.c |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2007-06-08 22:02:31 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [2552]
   - use g_random_double_ranged()
--- a/src/paranormal/libcalc/dict.c	Sat Jun 09 06:10:17 2007 -0700
+++ b/src/paranormal/libcalc/dict.c	Sat Jun 09 06:16:03 2007 -0700
@@ -35,8 +35,7 @@
 
   dict->v_space += V_SPACE_INCR;
 
-  new_var = (var_t *)g_malloc (dict->v_space * sizeof(var_t));
-
+  new_var = g_new(var_t, dict->v_space + 1);
   memcpy (new_var, dict->variables, dict->v_count * sizeof(var_t));
   g_free (dict->variables);
 
@@ -65,7 +64,7 @@
 
     global_dict.v_count = 0;
     global_dict.v_space = V_SPACE_INIT;
-    global_dict.variables = (var_t *) g_new(var_t, global_dict.v_space);
+    global_dict.variables = (var_t *) g_new(var_t, global_dict.v_space + 1);
     global_dict_initialized = 1;
 
     for (i = 0; i < 100; i++) {
@@ -80,7 +79,7 @@
   /* Allocate space for variables. */
   dict->v_count = 0;
   dict->v_space = V_SPACE_INIT;
-  dict->variables = (var_t *) g_new (var_t, dict->v_space);
+  dict->variables = (var_t *) g_new (var_t, dict->v_space + 1);
   
   return dict;
 }