summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-08-13 00:30:49 -0400
committerJune McEnroe <june@causal.agency>2019-08-13 00:30:49 -0400
commit16281106ebd66b98741d298df90b8fe1be360dbc (patch)
treefeb5a242901ca908827aaa44059066d6a0aa74a7
parentSet up afl-fuzz (diff)
downloadstream-16281106ebd66b98741d298df90b8fe1be360dbc.tar.gz
stream-16281106ebd66b98741d298df90b8fe1be360dbc.zip
Avoid inserting or deleting 0
Diffstat (limited to '')
-rw-r--r--term.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/term.c b/term.c
index a557725..5814f33 100644
--- a/term.c
+++ b/term.c
@@ -54,6 +54,7 @@ static void move(struct Cell *dst, struct Cell *src, uint len) {
 }
 
 static void scrollUp(struct Term *term, uint top, uint n) {
+	if (!n) return;
 	move(
 		cell(term, top, 0),
 		cell(term, top + n, 0),
@@ -67,6 +68,7 @@ static void scrollUp(struct Term *term, uint top, uint n) {
 }
 
 static void scrollDown(struct Term *term, uint top, uint n) {
+	if (!n) return;
 	move(
 		cell(term, top + n, 0),
 		cell(term, top, 0),
@@ -177,12 +179,12 @@ ACTION(ech) {
 }
 
 ACTION(dch) {
-	uint n = MIN(P(0, 1), t->cols - X);
+	uint n = MIN(P(0, 1), t->cols - X); if (!n) return;
 	move(C(Y, X), C(Y, X + n), t->cols - X - n);
 	erase(t->style, C(Y, t->cols - n), C(Y, R));
 }
 ACTION(ich) {
-	uint n = MIN(P(0, 1), t->cols - X);
+	uint n = MIN(P(0, 1), t->cols - X); if (!n) return;
 	move(C(Y, X + n), C(Y, X), t->cols - X - n);
 	erase(t->style, C(Y, X), C(Y, X + n - 1));
 }