summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2013-05-15 15:39:51 +0000
committernicm <nicm@openbsd.org>2013-05-15 15:39:51 +0000
commita5ccd6369eeb81cbdd5b8650701c1704b39a17ff (patch)
tree3a2ae72e584f904b76bcc70cd4b915452552989c
parentReserve space for \0 in cmd_print, from George Nachman. (diff)
downloadwireguard-openbsd-a5ccd6369eeb81cbdd5b8650701c1704b39a17ff.tar.xz
wireguard-openbsd-a5ccd6369eeb81cbdd5b8650701c1704b39a17ff.zip
Don't let cursor position overflow when reflowing, from Christopher
Collins.
-rw-r--r--usr.bin/tmux/screen.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c
index aa4cc16b6dc..408c2818f18 100644
--- a/usr.bin/tmux/screen.c
+++ b/usr.bin/tmux/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.25 2013/03/21 16:12:10 nicm Exp $ */
+/* $OpenBSD: screen.c,v 1.26 2013/05/15 15:39:51 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -365,7 +365,13 @@ void
screen_reflow(struct screen *s, u_int new_x)
{
struct grid *old = s->grid;
+ u_int change;
s->grid = grid_create(old->sx, old->sy, old->hlimit);
- s->cy -= grid_reflow(s->grid, old, new_x);
+
+ change = grid_reflow(s->grid, old, new_x);
+ if (change < s->cy)
+ s->cy -= change;
+ else
+ s->cy = 0;
}