summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2014-08-18 21:07:53 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2014-08-18 21:07:53 +0000
commita76386cba793369342a8bb5bb809d74d6158d938 (patch)
treed19e8d9489c57f0d8a119a303b40fcb7daa14066 /term.c
parent4720797aad300924396f0e81ac41b4aaf9863dea (diff)
downloadmandoc-a76386cba793369342a8bb5bb809d74d6158d938.tar.gz
Control reading off the edge of our buffer in term_flushln().
This happens in specific conditions (trailing whitespace in certain terminal modes), but in practise, it happens quite often (as reported by valgrind). In short, "Nothing about term_flushln() is simple. Srsly!" (schwarze@) Discussed on tech@, ok schwarze@.
Diffstat (limited to 'term.c')
-rw-r--r--term.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/term.c b/term.c
index fb00fa62..f1e959a2 100644
--- a/term.c
+++ b/term.c
@@ -220,7 +220,7 @@ term_flushln(struct termp *p)
break;
if (' ' == p->buf[i]) {
j = i;
- while (' ' == p->buf[i])
+ while (i < p->col && ' ' == p->buf[i])
i++;
dv = (i - j) * (*p->width)(p, ' ');
vbl += dv;