diff options
author | Eli Zaretskii <eliz@gnu.org> | 2013-10-11 14:01:48 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2013-10-11 14:01:48 +0300 |
commit | 48621e69064ea74eef6530d299cdc3548e170ce2 (patch) | |
tree | 783dc060c8f9dda66307e6f561d5dc178f0d31ec /src/xdisp.c | |
parent | b9ff995e4c091ca99c8752bb996e155ce7147a00 (diff) |
Fix bug #15575 with crashes in TTY menus.
src/xdisp.c (display_tty_menu_item): Make sure we never write beyond
the end of the frame's glyph matrix.
src/term.c (tty_menu_display): Don't move cursor while overwriting
frame's glyphs with menu items. Limit the number of items
displayed to what can be shown on the available screen lines,
excluding the echo area.
(tty_menu_activate): Limit the Y coordinate allowed by
read_menu_input to the last screen line used for menu display.
Diffstat (limited to 'src/xdisp.c')
-rw-r--r-- | src/xdisp.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 6c189c698e..7cfb0ab51a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -20640,6 +20640,14 @@ display_tty_menu_item (const char *item_text, int width, int face_id, eassert (FRAME_TERMCAP_P (f)); + /* Don't write beyond the matrix's last row. This can happen for + TTY screens that are not high enough to show the entire menu. + (This is actually a bit of defensive programming, as + tty_menu_display already limits the number of menu items to one + less than the number of screen lines.) */ + if (y >= f->desired_matrix->nrows) + return; + init_iterator (&it, w, -1, -1, f->desired_matrix->rows + y, MENU_FACE_ID); it.first_visible_x = 0; it.last_visible_x = FRAME_COLS (f) - 1; @@ -20654,6 +20662,7 @@ display_tty_menu_item (const char *item_text, int width, int face_id, /* Arrange for the menu item glyphs to start at (X,Y) and have the desired face. */ + eassert (x < f->desired_matrix->matrix_w); it.current_x = it.hpos = x; it.current_y = it.vpos = y; saved_used = row->used[TEXT_AREA]; |