summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-05-05 09:29:32 +0000
committerbapt <bapt@FreeBSD.org>2015-05-05 09:29:32 +0000
commit8224924ecc21a6daf1fed7e728b8133b7e5821db (patch)
tree5c9295e563e57bf5a08b26164616b4ee8693ae32
parenta7c69e6c584b3caca1f276d613965dbd251cc971 (diff)
downloadFreeBSD-src-8224924ecc21a6daf1fed7e728b8133b7e5821db.zip
FreeBSD-src-8224924ecc21a6daf1fed7e728b8133b7e5821db.tar.gz
Ensure we read existing values of the stk table
Obtained from: NetBSD
-rw-r--r--usr.bin/checknr/checknr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c
index 01d3216..c150b79 100644
--- a/usr.bin/checknr/checknr.c
+++ b/usr.bin/checknr/checknr.c
@@ -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);
OpenPOWER on IntegriCloud