selection: ensure start/end coordinates are bounded by the current grid

Closes #924
This commit is contained in:
Daniel Eklöf 2022-02-07 13:56:55 +01:00
parent 3baf7de3b8
commit 2e828248d0
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1108,16 +1108,8 @@ selection_finalize(struct seat *seat, struct terminal *term, uint32_t serial)
xassert(term->selection.start.row != -1);
xassert(term->selection.end.row != -1);
if (term->selection.start.row > term->selection.end.row ||
(term->selection.start.row == term->selection.end.row &&
term->selection.start.col > term->selection.end.col))
{
struct coord tmp = term->selection.start;
term->selection.start = term->selection.end;
term->selection.end = tmp;
}
xassert(term->selection.start.row <= term->selection.end.row);
term->selection.start.row &= (term->grid->num_rows - 1);
term->selection.end.row &= (term->grid->num_rows - 1);
switch (term->conf->selection_target) {
case SELECTION_TARGET_NONE: