aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-08-15 05:07:01 +0000
committerRichard M. Stallman1997-08-15 05:07:01 +0000
commit6c2935e99fd15a0c10a4a648a09a499076e031c1 (patch)
tree5e0586ccffd17ef83c0fe5cc2d4a2cf0286c5d54 /src
parent74700529a8ff91b367bc42cba61c2b0e6c5deb4f (diff)
downloademacs-6c2935e99fd15a0c10a4a648a09a499076e031c1.tar.gz
emacs-6c2935e99fd15a0c10a4a648a09a499076e031c1.zip
(main): Update re_max_failures so regex.c won't overflow
the stack, except when dumping.
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 59be6c7797b..366f7dadaa9 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -579,12 +579,19 @@ main (argc, argv, envp)
579#endif /* VMS */ 579#endif /* VMS */
580 580
581#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) 581#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
582 /* Extend the stack space available. */ 582 /* Extend the stack space available.
583 if (!getrlimit (RLIMIT_STACK, &rlim)) 583 Don't do that if dumping, since some systems (e.g. DJGPP)
584 might define a smaller stack limit at that time. */
585 if (1
586#ifndef CANNOT_DUMP
587 && (!noninteractive || initialized)
588#endif
589 && !getrlimit (RLIMIT_STACK, &rlim))
584 { 590 {
585 long newlim; 591 long newlim;
592 extern int re_max_failures;
586 /* Approximate the amount regex.c needs, plus some more. */ 593 /* Approximate the amount regex.c needs, plus some more. */
587 newlim = 800000 * sizeof (char *); 594 newlim = re_max_failures * 2 * 20 * sizeof (char *);
588#ifdef __NetBSD__ 595#ifdef __NetBSD__
589 /* NetBSD (at least NetBSD 1.2G and former) has a bug in its 596 /* NetBSD (at least NetBSD 1.2G and former) has a bug in its
590 stack allocation routine for new process that the allocation 597 stack allocation routine for new process that the allocation
@@ -593,7 +600,11 @@ main (argc, argv, envp)
593 newlim = (newlim + getpagesize () - 1) / getpagesize () * getpagesize(); 600 newlim = (newlim + getpagesize () - 1) / getpagesize () * getpagesize();
594#endif 601#endif
595 if (newlim > rlim.rlim_max) 602 if (newlim > rlim.rlim_max)
596 newlim = rlim.rlim_max; 603 {
604 newlim = rlim.rlim_max;
605 /* Don't let regex.c overflow the stack. */
606 re_max_failures = newlim / (2 * 20 * sizeof (char *));
607 }
597 if (rlim.rlim_cur < newlim) 608 if (rlim.rlim_cur < newlim)
598 rlim.rlim_cur = newlim; 609 rlim.rlim_cur = newlim;
599 610