diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-03-10 16:37:11 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-03-10 16:37:11 +0000 |
| commit | e2b3eb91ddfb8690d45d4300f0f41cbb1137f22e (patch) | |
| tree | 6b614cc801d7b27ff72cf5ab83afaf0196f15d38 /csi.c | |
| parent | changelog: rectangular functions: add bug ref (diff) | |
csi: params_to_rectangular_area(): ensure left/right is within bounds
Diffstat (limited to 'csi.c')
| -rw-r--r-- | csi.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; } |
