selection: find_word_boundary: ensure row number is bounded

This commit is contained in:
Daniel Eklöf 2023-10-03 14:07:41 +02:00
parent ddf4eb3b78
commit ca128ae380
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -345,12 +345,13 @@ void
selection_find_word_boundary_left(const struct terminal *term, struct coord *pos, selection_find_word_boundary_left(const struct terminal *term, struct coord *pos,
bool spaces_only) bool spaces_only)
{ {
xassert(pos->row >= 0); const struct grid *grid = term->grid;
xassert(pos->row < term->grid->num_rows);
xassert(pos->col >= 0); xassert(pos->col >= 0);
xassert(pos->col < term->cols); 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]; const struct row *r = grid->rows[pos->row];
char32_t c = r->cells[pos->col].wc; 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 spaces_only,
bool stop_on_space_to_word_boundary) bool stop_on_space_to_word_boundary)
{ {
xassert(pos->row >= 0); const struct grid *grid = term->grid;
xassert(pos->row < term->grid->num_rows);
xassert(pos->col >= 0); xassert(pos->col >= 0);
xassert(pos->col < term->cols); 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]; const struct row *r = grid->rows[pos->row];
char32_t c = r->cells[pos->col].wc; char32_t c = r->cells[pos->col].wc;