mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
csi: params_to_rectangular_area(): ensure left/right is within bounds
This commit is contained in:
parent
4ea4e5da4e
commit
e2b3eb91dd
1 changed files with 3 additions and 2 deletions
5
csi.c
5
csi.c
|
|
@ -678,15 +678,16 @@ params_to_rectangular_area(const struct terminal *term, int first_idx,
|
|||
int *top, int *left, int *bottom, int *right)
|
||||
{
|
||||
int rel_top = vt_param_get(term, first_idx + 0, 1) - 1;
|
||||
*left = vt_param_get(term, first_idx + 1, 1) - 1;
|
||||
*left = min(vt_param_get(term, first_idx + 1, 1) - 1, term->cols - 1);
|
||||
int rel_bottom = vt_param_get(term, first_idx + 2, term->rows) - 1;
|
||||
*right = vt_param_get(term, first_idx + 3, term->cols) - 1;
|
||||
*right = min(vt_param_get(term, first_idx + 3, term->cols) - 1, term->cols - 1);
|
||||
|
||||
if (rel_top > rel_bottom || *left > *right)
|
||||
return false;
|
||||
|
||||
*top = term_row_rel_to_abs(term, rel_top);
|
||||
*bottom = term_row_rel_to_abs(term, rel_bottom);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue