Fix SAFE_ALLOCA to not exhaust the stack when in a loop.
commit906ca07a4945558c2bb2e397bdd156583a78046a
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 23 Sep 2014 05:42:47 +0000 (22 22:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 23 Sep 2014 05:42:47 +0000 (22 22:42 -0700)
tree7462464fc2559ba2a347fa41eb304bc51b6618bf
parentd29b3c12b0671fb94f064e8219e8ec61a867e5a5
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.
src/ChangeLog
src/callproc.c
src/lisp.h