From 0de1ac95e5fe91e71061120de314b9bd852c2303 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 2 Sep 2015 18:56:20 +0100 Subject: [PATCH] Fix assertion failure in xterm mouse tracking. The original version of the xterm mouse tracking protocol did not support character-cell coordinates greater than 223. If term_mouse() got one, it would fail to construct an escape sequence for the mouse event, and would then call ldisc_send() with a zero-length string - which fails an assertion that I added in November (c269dd0135) on the occasion of moving ldisc_echoedit_update() into its own function. So the corresponding operation before that change would have done a gratuitous ldisc_echoedit_update(), which is exactly the sort of thing the assertion was there to catch :-) Later extensions to the mouse tracking protocol support larger coordinates anyway (try ESC[?1006h or ESC[?1015h in addition to the ESC[?1000h that turns the whole system on in the first place). It's only clients that don't use one of those extensions which would have had the problem. Thanks to Mirko Wolle for the report. --- terminal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index dc727238..590f456a 100644 --- a/terminal.c +++ b/terminal.c @@ -6043,7 +6043,8 @@ void term_mouse(Terminal *term, Mouse_Button braw, Mouse_Button bcooked, } else if (c <= 223 && r <= 223) { len = sprintf(abuf, "\033[M%c%c%c", encstate + 32, c + 32, r + 32); } - ldisc_send(term->ldisc, abuf, len, 0); + if (len > 0) + ldisc_send(term->ldisc, abuf, len, 0); } return; } -- 2.45.2