aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorPaul Eggert2011-09-30 22:57:41 -0700
committerPaul Eggert2011-09-30 22:57:41 -0700
commit39b5db3b1bb51088830bdf2d5e50940d462573d2 (patch)
treec542d4843a117800093a0258de4699ff5bb2321d /src/bytecode.c
parent79cce3f2364019ca04f34857e01c76c4e7b39004 (diff)
downloademacs-39b5db3b1bb51088830bdf2d5e50940d462573d2.tar.gz
emacs-39b5db3b1bb51088830bdf2d5e50940d462573d2.zip
* bytecode.c (unmark_byte_stack, exec_byte_code): use ptrdiff_t, not int.
(exec_byte_code): Use tighter memory-full test, one that checks for alloca overflow. Do not compute the address of the object just before an array.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index b6ac6c51bed..4a414b41712 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -318,7 +318,7 @@ unmark_byte_stack (void)
318 { 318 {
319 if (stack->byte_string_start != SDATA (stack->byte_string)) 319 if (stack->byte_string_start != SDATA (stack->byte_string))
320 { 320 {
321 int offset = stack->pc - stack->byte_string_start; 321 ptrdiff_t offset = stack->pc - stack->byte_string_start;
322 stack->byte_string_start = SDATA (stack->byte_string); 322 stack->byte_string_start = SDATA (stack->byte_string);
323 stack->pc = stack->byte_string_start + offset; 323 stack->pc = stack->byte_string_start + offset;
324 } 324 }
@@ -446,7 +446,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
446#ifdef BYTE_CODE_SAFE 446#ifdef BYTE_CODE_SAFE
447 ptrdiff_t const_length; 447 ptrdiff_t const_length;
448 Lisp_Object *stacke; 448 Lisp_Object *stacke;
449 int bytestr_length; 449 ptrdiff_t bytestr_length;
450#endif 450#endif
451 struct byte_stack stack; 451 struct byte_stack stack;
452 Lisp_Object *top; 452 Lisp_Object *top;
@@ -486,13 +486,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
486 stack.byte_string = bytestr; 486 stack.byte_string = bytestr;
487 stack.pc = stack.byte_string_start = SDATA (bytestr); 487 stack.pc = stack.byte_string_start = SDATA (bytestr);
488 stack.constants = vector; 488 stack.constants = vector;
489 top = (Lisp_Object *) alloca (XFASTINT (maxdepth) 489 if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth))
490 memory_full (SIZE_MAX);
491 top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1)
490 * sizeof (Lisp_Object)); 492 * sizeof (Lisp_Object));
491#if BYTE_MAINTAIN_TOP 493#if BYTE_MAINTAIN_TOP
492 stack.bottom = top; 494 stack.bottom = top + 1;
493 stack.top = NULL; 495 stack.top = NULL;
494#endif 496#endif
495 top -= 1;
496 stack.next = byte_stack_list; 497 stack.next = byte_stack_list;
497 byte_stack_list = &stack; 498 byte_stack_list = &stack;
498 499