indent(1): Bail out if there's no more space on the parser stack.
Also increase the stack size still keeping a conservative value of 256. This is based on a similar changes done for PostgreSQL which instead uses a stack size of 1000. Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Submitted by: Piotr Stefaniak (with changes)
This commit is contained in:
parent
11c4989364
commit
5467ab90aa
@ -226,7 +226,7 @@ struct fstate
|
||||
bodyf; /* major body font */
|
||||
|
||||
|
||||
#define STACKSIZE 150
|
||||
#define STACKSIZE 256
|
||||
|
||||
struct parser_state {
|
||||
int last_token;
|
||||
|
@ -42,6 +42,7 @@ static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/6/93";
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include "indent_globs.h"
|
||||
#include "indent_codes.h"
|
||||
@ -200,6 +201,9 @@ parse(int tk) /* tk: the code for the construct scanned */
|
||||
|
||||
} /* end of switch */
|
||||
|
||||
if (ps.tos >= STACKSIZE)
|
||||
errx(1, "Parser stack overflow");
|
||||
|
||||
reduce(); /* see if any reduction can be done */
|
||||
|
||||
#ifdef debug
|
||||
|
Loading…
Reference in New Issue
Block a user