diff options
| author | Paul Eggert | 2014-09-22 22:42:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-09-22 22:42:47 -0700 |
| commit | cb8e2bfba7e712815203264a0c40bf2da1ff4e64 (patch) | |
| tree | 72b730a1653aa4987e338042b7f5297f9bcf7071 /src/callproc.c | |
| parent | 9949231fb06aa4a2dfa536e9d5125a81424db3a7 (diff) | |
| download | emacs-cb8e2bfba7e712815203264a0c40bf2da1ff4e64.tar.gz emacs-cb8e2bfba7e712815203264a0c40bf2da1ff4e64.zip | |
Fix SAFE_ALLOCA to not exhaust the stack when in a loop.
Problem reported by Dmietry Antipov in thread leading to:
http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00713.html
This patch fixes only SAFE_ALLOCA, SAFE_NALLOCA, and SAFE_ALLOCA_LISP;
the experimental local_* macros enabled by USE_LOCAL_ALLOCATORS
remain unfixed.
* callproc.c (call_process): Save and restore sa_avail.
* lisp.h (USE_SAFE_ALLOCA): Define sa_avail.
(AVAIL_ALLOCA): New macro.
(SAFE_ALLOCA, SAFE_NALLOCA, SAFE_ALLOCA_LISP):
Use it, and check against sa_avail rather than MAX_ALLOCA.
Diffstat (limited to 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/callproc.c b/src/callproc.c index 798f441bdef..4bedf671e83 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -632,6 +632,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 632 | int volatile fd_error_volatile = fd_error; | 632 | int volatile fd_error_volatile = fd_error; |
| 633 | int volatile filefd_volatile = filefd; | 633 | int volatile filefd_volatile = filefd; |
| 634 | ptrdiff_t volatile count_volatile = count; | 634 | ptrdiff_t volatile count_volatile = count; |
| 635 | ptrdiff_t volatile sa_avail_volatile = sa_avail; | ||
| 635 | ptrdiff_t volatile sa_count_volatile = sa_count; | 636 | ptrdiff_t volatile sa_count_volatile = sa_count; |
| 636 | char **volatile new_argv_volatile = new_argv; | 637 | char **volatile new_argv_volatile = new_argv; |
| 637 | int volatile callproc_fd_volatile[CALLPROC_FDS]; | 638 | int volatile callproc_fd_volatile[CALLPROC_FDS]; |
| @@ -648,6 +649,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 648 | fd_error = fd_error_volatile; | 649 | fd_error = fd_error_volatile; |
| 649 | filefd = filefd_volatile; | 650 | filefd = filefd_volatile; |
| 650 | count = count_volatile; | 651 | count = count_volatile; |
| 652 | sa_avail = sa_avail_volatile; | ||
| 651 | sa_count = sa_count_volatile; | 653 | sa_count = sa_count_volatile; |
| 652 | new_argv = new_argv_volatile; | 654 | new_argv = new_argv_volatile; |
| 653 | 655 | ||