From ca887f8d070d0bd2da705d10b9719d50b702f134 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 5 May 2015 09:29:32 +0000 Subject: [PATCH] Ensure we read existing values of the stk table Obtained from: NetBSD --- usr.bin/checknr/checknr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c index 01d3216afc5..c150b795e41 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);