aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-03-25 21:17:38 -0700
committerPaul Eggert2011-03-25 21:17:38 -0700
commitdd3f25f792d724f59fac3e2d4faa21b311f21137 (patch)
tree4c2934367628c4dbe84151dd7ca6bc83c6058b50 /src
parent59eb0929f7ae29f9c970c4188c90c1b460e820a9 (diff)
downloademacs-dd3f25f792d724f59fac3e2d4faa21b311f21137.tar.gz
emacs-dd3f25f792d724f59fac3e2d4faa21b311f21137.zip
* alloc.c (garbage_collect): Don't assume stack size fits in int.
(stack_copy_size): Now size_t, not int. (stack_copy, stack_copy_size): Define only if MAX_SAVE_STACK > 0.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/alloc.c33
2 files changed, 26 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cc40c863e97..cf9ca86a798 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12011-03-26 Paul Eggert <eggert@cs.ucla.edu>
2
3 * alloc.c (garbage_collect): Don't assume stack size fits in int.
4 (stack_copy_size): Now size_t, not int.
5 (stack_copy, stack_copy_size): Define only if MAX_SAVE_STACK > 0.
6
12011-03-26 Juanma Barranquero <lekktu@gmail.com> 72011-03-26 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * w32.c (read_unc_volume): Use parameter `henum', instead of 9 * w32.c (read_unc_volume): Use parameter `henum', instead of
diff --git a/src/alloc.c b/src/alloc.c
index 66695e7a9bc..00f053e9090 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -254,8 +254,10 @@ const char *pending_malloc_warning;
254 254
255/* Buffer in which we save a copy of the C stack at each GC. */ 255/* Buffer in which we save a copy of the C stack at each GC. */
256 256
257#if MAX_SAVE_STACK > 0
257static char *stack_copy; 258static char *stack_copy;
258static int stack_copy_size; 259static size_t stack_copy_size;
260#endif
259 261
260/* Non-zero means ignore malloc warnings. Set during initialization. 262/* Non-zero means ignore malloc warnings. Set during initialization.
261 Currently not used. */ 263 Currently not used. */
@@ -4903,21 +4905,26 @@ returns nil, because real GC can't be done. */)
4903#if MAX_SAVE_STACK > 0 4905#if MAX_SAVE_STACK > 0
4904 if (NILP (Vpurify_flag)) 4906 if (NILP (Vpurify_flag))
4905 { 4907 {
4906 i = &stack_top_variable - stack_bottom; 4908 char *stack;
4907 if (i < 0) i = -i; 4909 size_t stack_size;
4908 if (i < MAX_SAVE_STACK) 4910 if (&stack_top_variable < stack_bottom)
4911 {
4912 stack = &stack_top_variable;
4913 stack_size = stack_bottom - &stack_top_variable;
4914 }
4915 else
4916 {
4917 stack = stack_bottom;
4918 stack_size = &stack_top_variable - stack_bottom;
4919 }
4920 if (stack_size <= MAX_SAVE_STACK)
4909 { 4921 {
4910 if (stack_copy == 0) 4922 if (stack_copy_size < stack_size)
4911 stack_copy = (char *) xmalloc (stack_copy_size = i);
4912 else if (stack_copy_size < i)
4913 stack_copy = (char *) xrealloc (stack_copy, (stack_copy_size = i));
4914 if (stack_copy)
4915 { 4923 {
4916 if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0) 4924 stack_copy = (char *) xrealloc (stack_copy, stack_size);
4917 memcpy (stack_copy, stack_bottom, i); 4925 stack_copy_size = stack_size;
4918 else
4919 memcpy (stack_copy, &stack_top_variable, i);
4920 } 4926 }
4927 memcpy (stack_copy, stack, stack_size);
4921 } 4928 }
4922 } 4929 }
4923#endif /* MAX_SAVE_STACK > 0 */ 4930#endif /* MAX_SAVE_STACK > 0 */