From 39b5db3b1bb51088830bdf2d5e50940d462573d2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 30 Sep 2011 22:57:41 -0700 Subject: [PATCH] * 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. --- src/ChangeLog | 10 ++++++---- src/bytecode.c | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bd20439ccc7..7da9270555a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -53,10 +53,12 @@ (struct buffer_text, struct buffer): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Use EMACS_INT, not int, where int might not be wide enough. - * bytecode.c (exec_byte_code): Use ptrdiff_t, not int, to avoid - needless 32-bit limit on 64-bit hosts. Remove unnecessary - memory-full test. Use EMACS_INT, not ptrdiff_t or int, where - ptrdiff_t or int might not be wide enough. + * bytecode.c (unmark_byte_stack, exec_byte_code): Use ptrdiff_t, + not int, to avoid needless 32-bit limit on 64-bit hosts. + (exec_byte_code): Use tighter memory-full test, one that checks + for alloca overflow. Don't compute the address of the object just + before an array, as that's not portable. Use EMACS_INT, not + ptrdiff_t or int, where ptrdiff_t or int might not be wide enough. * callint.c (Fcall_interactively): Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. * callproc.c (call_process_kill, Fcall_process): 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) { if (stack->byte_string_start != SDATA (stack->byte_string)) { - int offset = stack->pc - stack->byte_string_start; + ptrdiff_t offset = stack->pc - stack->byte_string_start; stack->byte_string_start = SDATA (stack->byte_string); stack->pc = stack->byte_string_start + offset; } @@ -446,7 +446,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #ifdef BYTE_CODE_SAFE ptrdiff_t const_length; Lisp_Object *stacke; - int bytestr_length; + ptrdiff_t bytestr_length; #endif struct byte_stack stack; Lisp_Object *top; @@ -486,13 +486,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, stack.byte_string = bytestr; stack.pc = stack.byte_string_start = SDATA (bytestr); stack.constants = vector; - top = (Lisp_Object *) alloca (XFASTINT (maxdepth) + if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth)) + memory_full (SIZE_MAX); + top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1) * sizeof (Lisp_Object)); #if BYTE_MAINTAIN_TOP - stack.bottom = top; + stack.bottom = top + 1; stack.top = NULL; #endif - top -= 1; stack.next = byte_stack_list; byte_stack_list = &stack; -- 2.39.2