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:
Pedro F. Giffuni 2016-07-31 04:58:06 +00:00
parent 11c4989364
commit 5467ab90aa
2 changed files with 5 additions and 1 deletions

View File

@ -226,7 +226,7 @@ struct fstate
bodyf; /* major body font */
#define STACKSIZE 150
#define STACKSIZE 256
struct parser_state {
int last_token;

View File

@ -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