mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Disallow REP escape sequence with no prior graphic char.
The REP escape (ESC [ nnn b) causes the previously printed graphic character to be repeated another nnn times. So if it's sent as the very first thing in a terminal session, when there _is_ no previously printed graphic character, there's nothing sensible it can do. In fact, in that situation, it does something decidedly _not_ sensible: it takes the uninitialised value term->last_graphic_char and sends it directly to term_display_graphic_char, with undesirable results if it's not actually a printing character. In particular, the value 0 is treated as a combining char (because it has zero wcwidth), leading to a knock-on assertion failure when compressing the scrollback lines (which uses \0 as a terminating value for sequences of combining characters, precisely because it expects it never to show up in an actual cc slot!).
This commit is contained in:
parent
d828549995
commit
3edc1b330d
@ -1711,6 +1711,8 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata, TermWin *win)
|
||||
term->n_mouse_select_clipboards = 1;
|
||||
term->mouse_paste_clipboard = CLIP_NULL;
|
||||
|
||||
term->last_graphic_char = 0;
|
||||
|
||||
return term;
|
||||
}
|
||||
|
||||
@ -3578,7 +3580,7 @@ static void term_out(Terminal *term)
|
||||
break;
|
||||
case 'b': /* REP: repeat previous grap */
|
||||
CLAMP(term->esc_args[0], term->rows * term->cols);
|
||||
{
|
||||
if (term->last_graphic_char) {
|
||||
unsigned i;
|
||||
for (i = 0; i < term->esc_args[0]; i++)
|
||||
term_display_graphic_char(
|
||||
|
Loading…
Reference in New Issue
Block a user