aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-10-03 12:07:41 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-10-08 08:38:39 +0000
commitca128ae3802dde3b2bafab190a09911589d23e8a (patch)
tree66d6ee75991ce78661813c8d1bf541600baa7143 /selection.c
parentsearch: don't try to extend a search match when there is none (diff)
selection: find_word_boundary: ensure row number is bounded
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/selection.c b/selection.c
index 8a3fd781..50e41637 100644
--- a/selection.c
+++ b/selection.c
@@ -345,12 +345,13 @@ void
selection_find_word_boundary_left(const struct terminal *term, struct coord *pos,
bool spaces_only)
{
- xassert(pos->row >= 0);
- xassert(pos->row < term->grid->num_rows);
+ const struct grid *grid = term->grid;
+
xassert(pos->col >= 0);
xassert(pos->col < term->cols);
+ xassert(pos->row >= 0);
+ pos->row &= grid->num_rows - 1;
- const struct grid *grid = term->grid;
const struct row *r = grid->rows[pos->row];
char32_t c = r->cells[pos->col].wc;
@@ -433,12 +434,13 @@ selection_find_word_boundary_right(const struct terminal *term, struct coord *po
bool spaces_only,
bool stop_on_space_to_word_boundary)
{
- xassert(pos->row >= 0);
- xassert(pos->row < term->grid->num_rows);
+ const struct grid *grid = term->grid;
+
xassert(pos->col >= 0);
xassert(pos->col < term->cols);
+ xassert(pos->row >= 0);
+ pos->row &= grid->num_rows - 1;
- const struct grid *grid = term->grid;
const struct row *r = grid->rows[pos->row];
char32_t c = r->cells[pos->col].wc;