summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/window-copy.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-07-11 19:09:24 +0000
committernicm <nicm@openbsd.org>2009-07-11 19:09:24 +0000
commit54ef2226d63cdc72d91d12626e6904734ae0538a (patch)
treeebfec33bdcc57061cffd2f30f83f45901ef9351d /usr.bin/tmux/window-copy.c
parentNuke an '__inline' that upset clang. Multi-line function should not (diff)
downloadwireguard-openbsd-54ef2226d63cdc72d91d12626e6904734ae0538a.tar.xz
wireguard-openbsd-54ef2226d63cdc72d91d12626e6904734ae0538a.zip
Copy was using the real line length which after resize can be larger than the
screen width. When built with -DDEBUG, this made the grid bounds checking code kill the server. Restrict copying to the actual width. From Kalle Olavi Niemitalo, thanks.
Diffstat (limited to 'usr.bin/tmux/window-copy.c')
-rw-r--r--usr.bin/tmux/window-copy.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index e3cc2db8037..3bb667e2422 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.3 2009/07/09 15:02:00 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.4 2009/07/11 19:09:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -522,7 +522,15 @@ window_copy_find_length(struct window_pane *wp, u_int py)
const struct grid_cell *gc;
u_int px;
+ /*
+ * If the pane has been resized, its grid can contain old overlong
+ * lines. grid_peek_cell does not allow accessing cells beyond the
+ * width of the grid, and screen_write_copy treats them as spaces, so
+ * ignore them here too.
+ */
px = wp->base.grid->size[py];
+ if (px > screen_size_x(&wp->base))
+ px = screen_size_x(&wp->base);
while (px > 0) {
gc = grid_peek_cell(wp->base.grid, px - 1, py);
if (gc->flags & GRID_FLAG_UTF8)