svn commit: r334578 - head/usr.bin/indent

Piotr Pawel Stefaniak pstef at FreeBSD.org
Sun Jun 3 18:29:21 UTC 2018


Author: pstef
Date: Sun Jun  3 18:29:20 2018
New Revision: 334578
URL: https://svnweb.freebsd.org/changeset/base/334578

Log:
  indent(1): don't overflow di_stack[]

Modified:
  head/usr.bin/indent/indent.c

Modified: head/usr.bin/indent/indent.c
==============================================================================
--- head/usr.bin/indent/indent.c	Sun Jun  3 18:19:48 2018	(r334577)
+++ head/usr.bin/indent/indent.c	Sun Jun  3 18:29:20 2018	(r334578)
@@ -831,7 +831,12 @@ check_type:
 					 * with '{' */
 	    if (ps.in_decl && ps.in_or_st) {	/* this is either a structure
 						 * declaration or an init */
-		di_stack[ps.dec_nest++] = dec_ind;
+		di_stack[ps.dec_nest] = dec_ind;
+		if (++ps.dec_nest == nitems(di_stack)) {
+		    diag3(0, "Reached internal limit of %d struct levels",
+			nitems(di_stack));
+		    ps.dec_nest--;
+		}
 		/* ?		dec_ind = 0; */
 	    }
 	    else {


More information about the svn-src-all mailing list