Author: bapt
Date: Tue May  5 09:29:32 2015
New Revision: 282464
URL: https://svnweb.freebsd.org/changeset/base/282464

Log:
  Ensure we read existing values of the stk table
  
  Obtained from:        NetBSD

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

Modified: head/usr.bin/checknr/checknr.c
==============================================================================
--- head/usr.bin/checknr/checknr.c      Tue May  5 09:26:32 2015        
(r282463)
+++ head/usr.bin/checknr/checknr.c      Tue May  5 09:29:32 2015        
(r282464)
@@ -341,7 +341,8 @@ process(FILE *f)
                                                n = 10 * n + line[i] - '0';
                                        i--;
                                        if (n == 0) {
-                                               if (stk[stktop].opno == SZ) {
+                                               if (stktop >= 0 &&
+                                                   stk[stktop].opno == SZ) {
                                                        stktop--;
                                                } else {
                                                        pe(lineno);
@@ -356,7 +357,8 @@ process(FILE *f)
                                } else if (!fflag && line[i] == 'f') {
                                        n = line[++i];
                                        if (n == 'P') {
-                                               if (stk[stktop].opno == FT) {
+                                               if (stktop >= 0 && 
+                                                   stk[stktop].opno == FT) {
                                                        stktop--;
                                                } else {
                                                        pe(lineno);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to