csi: clamp REP count to scrollback-lines * cols

This can be quite a lot, but hopefully less than 0x7fffffff, which is
the max value a VT parameter can have...

Closes #2366
This commit is contained in:
Daniel Eklöf 2026-06-24 13:06:16 +02:00
parent 01b3e7ed92
commit e24ad0a793
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

3
csi.c
View file

@ -798,7 +798,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
* ECMA-48, the behaviour is undefined if REP was
* _not_ preceded by a graphical character.
*/
int count = vt_param_get(term, 0, 1);
const size_t max_count = term->grid->num_rows * term->cols;
int count = min(vt_param_get(term, 0, 1), max_count);
LOG_DBG("REP: '%lc' %d times", (wint_t)term->vt.last_printed, count);
int width;