aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-05 14:38:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-05 14:38:45 +0000
commit6833abf33cb168716bf57f9eb170a293fe918d53 (patch)
tree37e11950883bc1849fc966909721668ae9e4b34c /selection.c
parentsearch: rename render.search_offset -> render.search_glyph_offset (diff)
selection: foreach_selection_*: must wrap row number
Fixes occasional crashes when we're at the end of the grid and selection wraps around.
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/selection.c b/selection.c
index 9a574169..7ea146f7 100644
--- a/selection.c
+++ b/selection.c
@@ -74,7 +74,9 @@ foreach_selected_normal(
}
for (int r = start_row; r <= end_row; r++) {
- struct row *row = term->grid->rows[r];
+ size_t real_r = r & (term->grid->num_rows - 1);
+ struct row *row = term->grid->rows[real_r];
+ assert(row != NULL);
for (int c = start_col;
c <= (r == end_row ? end_col : term->cols - 1);
@@ -107,7 +109,9 @@ foreach_selected_block(
};
for (int r = top_left.row; r <= bottom_right.row; r++) {
- struct row *row = term->grid->rows[r];
+ size_t real_r = r & (term->grid->num_rows - 1);
+ struct row *row = term->grid->rows[real_r];
+ assert(row != NULL);
for (int c = top_left.col; c <= bottom_right.col; c++)
cb(term, row, &row->cells[c], data);