aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-07-12 17:11:07 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-07-12 17:11:07 +0000
commitd8de72ca77a6bbe2e8b9244480d700d343a6a656 (patch)
tree12d608f1e33bbe86b8bc534066b3c459a84e51d2
parentef5f356da2a40592b3583059af8a4a7f163da27a (diff)
downloadrtmux-d8de72ca77a6bbe2e8b9244480d700d343a6a656.tar.gz
rtmux-d8de72ca77a6bbe2e8b9244480d700d343a6a656.tar.bz2
rtmux-d8de72ca77a6bbe2e8b9244480d700d343a6a656.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.
-rw-r--r--window-copy.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/window-copy.c b/window-copy.c
index a8a9a762..1bbf8b9a 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1,4 +1,4 @@
-/* $Id: window-copy.c,v 1.62 2009-07-12 16:56:56 nicm Exp $ */
+/* $Id: window-copy.c,v 1.63 2009-07-12 17:11:07 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)