selection: find_word_boundary: assert ‘pos’ is valid

This commit is contained in:
Daniel Eklöf 2022-04-23 12:23:27 +02:00
parent 47d1ba58e5
commit 8c0fca30db
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -270,6 +270,11 @@ void
selection_find_word_boundary_left(struct terminal *term, struct coord *pos, selection_find_word_boundary_left(struct terminal *term, struct coord *pos,
bool spaces_only) bool spaces_only)
{ {
xassert(pos->row >= 0);
xassert(pos->row < term->rows);
xassert(pos->col >= 0);
xassert(pos->col < term->cols);
const struct row *r = grid_row_in_view(term->grid, pos->row); const struct row *r = grid_row_in_view(term->grid, pos->row);
char32_t c = r->cells[pos->col].wc; char32_t c = r->cells[pos->col].wc;
@ -343,6 +348,11 @@ void
selection_find_word_boundary_right(struct terminal *term, struct coord *pos, selection_find_word_boundary_right(struct terminal *term, struct coord *pos,
bool spaces_only) bool spaces_only)
{ {
xassert(pos->row >= 0);
xassert(pos->row < term->rows);
xassert(pos->col >= 0);
xassert(pos->col < term->cols);
const struct row *r = grid_row_in_view(term->grid, pos->row); const struct row *r = grid_row_in_view(term->grid, pos->row);
char32_t c = r->cells[pos->col].wc; char32_t c = r->cells[pos->col].wc;