indent(1): Avoid out of bounds access of array ps.paren_indents

ps.p_l_follow can't be allowed to grow beyond maximum index of paren_indents.

Approved by:	pfg (mentor)
This commit is contained in:
Piotr Pawel Stefaniak 2016-12-30 21:00:45 +00:00
parent c560956880
commit 93567e8778
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=310863

View File

@ -525,7 +525,12 @@ main(int argc, char **argv)
break;
case lparen: /* got a '(' or '[' */
++ps.p_l_follow; /* count parens to make Healy happy */
/* count parens to make Healy happy */
if (++ps.p_l_follow == nitems(ps.paren_indents)) {
diag3(0, "Reached internal limit of %d unclosed parens",
nitems(ps.paren_indents));
ps.p_l_follow--;
}
if (ps.want_blank && *token != '[' &&
(ps.last_token != ident || proc_calls_space ||
/* offsetof (1) is never allowed a space; sizeof (2) gets