Commit 39b5db3b authored by Paul Eggert's avatar Paul Eggert

* 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.
parent 79cce3f2
...@@ -53,10 +53,12 @@ ...@@ -53,10 +53,12 @@
(struct buffer_text, struct buffer): (struct buffer_text, struct buffer):
Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough.
Use EMACS_INT, not int, where int might not be 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 * bytecode.c (unmark_byte_stack, exec_byte_code): Use ptrdiff_t,
needless 32-bit limit on 64-bit hosts. Remove unnecessary not int, to avoid needless 32-bit limit on 64-bit hosts.
memory-full test. Use EMACS_INT, not ptrdiff_t or int, where (exec_byte_code): Use tighter memory-full test, one that checks
ptrdiff_t or int might not be wide enough. 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): * callint.c (Fcall_interactively):
Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts. Use ptrdiff_t, not int, to avoid needless 32-bit limit on 64-bit hosts.
* callproc.c (call_process_kill, Fcall_process): * callproc.c (call_process_kill, Fcall_process):
......
...@@ -318,7 +318,7 @@ unmark_byte_stack (void) ...@@ -318,7 +318,7 @@ unmark_byte_stack (void)
{ {
if (stack->byte_string_start != SDATA (stack->byte_string)) 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->byte_string_start = SDATA (stack->byte_string);
stack->pc = stack->byte_string_start + offset; stack->pc = stack->byte_string_start + offset;
} }
...@@ -446,7 +446,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, ...@@ -446,7 +446,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
#ifdef BYTE_CODE_SAFE #ifdef BYTE_CODE_SAFE
ptrdiff_t const_length; ptrdiff_t const_length;
Lisp_Object *stacke; Lisp_Object *stacke;
int bytestr_length; ptrdiff_t bytestr_length;
#endif #endif
struct byte_stack stack; struct byte_stack stack;
Lisp_Object *top; Lisp_Object *top;
...@@ -486,13 +486,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, ...@@ -486,13 +486,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
stack.byte_string = bytestr; stack.byte_string = bytestr;
stack.pc = stack.byte_string_start = SDATA (bytestr); stack.pc = stack.byte_string_start = SDATA (bytestr);
stack.constants = vector; 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)); * sizeof (Lisp_Object));
#if BYTE_MAINTAIN_TOP #if BYTE_MAINTAIN_TOP
stack.bottom = top; stack.bottom = top + 1;
stack.top = NULL; stack.top = NULL;
#endif #endif
top -= 1;
stack.next = byte_stack_list; stack.next = byte_stack_list;
byte_stack_list = &stack; byte_stack_list = &stack;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment