Author: pfg
Date: Fri Dec  2 16:42:45 2016
New Revision: 309419
URL: https://svnweb.freebsd.org/changeset/base/309419

Log:
  indent(1): Avoid out-of-bound accesses of array ps.p_stack.
  
  Submitted by:  Piotr Stefaniak

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

Modified: head/usr.bin/indent/parse.c
==============================================================================
--- head/usr.bin/indent/parse.c Fri Dec  2 16:41:08 2016        (r309418)
+++ head/usr.bin/indent/parse.c Fri Dec  2 16:42:45 2016        (r309419)
@@ -172,7 +172,7 @@ parse(int tk) /* tk: the code for the co
 
     case rbrace:               /* scanned a } */
        /* stack should have <lbrace> <stmt> or <lbrace> <stmtl> */
-       if (ps.p_stack[ps.tos - 1] == lbrace) {
+       if (ps.tos > 0 && ps.p_stack[ps.tos - 1] == lbrace) {
            ps.ind_level = ps.i_l_follow = ps.il[--ps.tos];
            ps.p_stack[ps.tos] = stmt;
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to