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:
pstef 2016-12-30 21:00:45 +00:00
parent 8f05209a8a
commit b6688beaf7

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