summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-05-04 14:50:25 +0000
committerpfg <pfg@FreeBSD.org>2017-05-04 14:50:25 +0000
commit78a86ecf90837d764bb6bed7785aea03ded2c62e (patch)
treea0e194c1d84ac1412f8dcec0a13e3cd243fb984b /usr.bin
parentaab0b84fb38432839992f6ac5442acff507caebb (diff)
downloadFreeBSD-src-78a86ecf90837d764bb6bed7785aea03ded2c62e.zip
FreeBSD-src-78a86ecf90837d764bb6bed7785aea03ded2c62e.tar.gz
MFC r317583:
Fix some cases where an index was used before its limits check. Obtained from: DragonFlyBSD (git 799ba435)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/unexpand/unexpand.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/unexpand/unexpand.c b/usr.bin/unexpand/unexpand.c
index 1ef5db1..dcbd7fb 100644
--- a/usr.bin/unexpand/unexpand.c
+++ b/usr.bin/unexpand/unexpand.c
@@ -132,8 +132,8 @@ tabify(const char *curfile)
tabstops[0];
continue;
} else {
- for (n = 0; tabstops[n] - 1 < dcol &&
- n < nstops; n++)
+ for (n = 0; n < nstops &&
+ tabstops[n] - 1 < dcol; n++)
;
if (n < nstops - 1 && tabstops[n] - 1 < limit) {
dcol = tabstops[n];
@@ -154,7 +154,7 @@ tabify(const char *curfile)
tabstops[0];
}
} else {
- for (n = 0; tabstops[n] - 1 < ocol && n < nstops; n++)
+ for (n = 0; n < nstops && tabstops[n] - 1 < ocol; n++)
;
while (ocol < dcol && n < nstops && ocol < limit) {
putwchar('\t');
OpenPOWER on IntegriCloud