diff options
| author | Eli Zaretskii | 2013-10-11 14:01:48 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-10-11 14:01:48 +0300 |
| commit | 48621e69064ea74eef6530d299cdc3548e170ce2 (patch) | |
| tree | 783dc060c8f9dda66307e6f561d5dc178f0d31ec /src/term.c | |
| parent | b9ff995e4c091ca99c8752bb996e155ce7147a00 (diff) | |
| download | emacs-48621e69064ea74eef6530d299cdc3548e170ce2.tar.gz emacs-48621e69064ea74eef6530d299cdc3548e170ce2.zip | |
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/term.c')
| -rw-r--r-- | src/term.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/term.c b/src/term.c index a4f8f2ea17c..9437faee8a2 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2919,17 +2919,20 @@ tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces, | |||
| 2919 | int i, face, width, enabled, mousehere, row, col; | 2919 | int i, face, width, enabled, mousehere, row, col; |
| 2920 | struct frame *sf = SELECTED_FRAME (); | 2920 | struct frame *sf = SELECTED_FRAME (); |
| 2921 | struct tty_display_info *tty = FRAME_TTY (sf); | 2921 | struct tty_display_info *tty = FRAME_TTY (sf); |
| 2922 | /* Don't try to display more menu items than the console can display | ||
| 2923 | using the available screen lines. Exclude the echo area line, as | ||
| 2924 | it will be overwritten by the help-echo anyway. */ | ||
| 2925 | int max_items = min (menu->count, FRAME_LINES (sf) - 1); | ||
| 2922 | 2926 | ||
| 2923 | menu_help_message = NULL; | 2927 | menu_help_message = NULL; |
| 2924 | 2928 | ||
| 2925 | width = menu->width; | 2929 | width = menu->width; |
| 2926 | col = cursorX (tty); | 2930 | col = cursorX (tty); |
| 2927 | row = cursorY (tty); | 2931 | row = cursorY (tty); |
| 2928 | for (i = 0; i < menu->count; i++) | 2932 | for (i = 0; i < max_items; i++) |
| 2929 | { | 2933 | { |
| 2930 | int max_width = width + 2; /* +2 for padding blanks on each side */ | 2934 | int max_width = width + 2; /* +2 for padding blanks on each side */ |
| 2931 | 2935 | ||
| 2932 | cursor_to (sf, y + i, x); | ||
| 2933 | if (menu->submenu[i]) | 2936 | if (menu->submenu[i]) |
| 2934 | max_width += 2; /* for displaying " >" after the item */ | 2937 | max_width += 2; /* for displaying " >" after the item */ |
| 2935 | enabled | 2938 | enabled |
| @@ -3285,7 +3288,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3285 | while (!leave) | 3288 | while (!leave) |
| 3286 | { | 3289 | { |
| 3287 | int input_status; | 3290 | int input_status; |
| 3288 | int min_y = state[0].y, max_y = min_y + state[0].menu->count - 1; | 3291 | int min_y = state[0].y; |
| 3292 | int max_y = min (min_y + state[0].menu->count, FRAME_LINES (sf)) - 1; | ||
| 3289 | 3293 | ||
| 3290 | input_status = read_menu_input (sf, &x, &y, min_y, max_y, &first_time); | 3294 | input_status = read_menu_input (sf, &x, &y, min_y, max_y, &first_time); |
| 3291 | if (input_status) | 3295 | if (input_status) |