diff src/alloc.c @ 68369:3422c551ad06

* alloc.c (allocate_string_data): Update next_free immediately, to reduce risk of memory clobberage.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 24 Jan 2006 18:35:25 +0000
parents 263a4edafafa
children cec05baae14f 5b7d410e31f9
line wrap: on
line diff
--- a/src/alloc.c	Tue Jan 24 17:14:16 2006 +0000
+++ b/src/alloc.c	Tue Jan 24 18:35:25 2006 +0000
@@ -1978,6 +1978,8 @@
   old_nbytes = GC_STRING_BYTES (s);
 
   data = b->next_free;
+  b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
+
   data->string = s;
   s->data = SDATA_DATA (data);
 #ifdef GC_CHECK_STRING_BYTES
@@ -1990,7 +1992,6 @@
   bcopy (string_overrun_cookie, (char *) data + needed,
 	 GC_STRING_OVERRUN_COOKIE_SIZE);
 #endif
-  b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
 
   /* If S had already data assigned, mark that as free by setting its
      string back-pointer to null, and recording the size of the data