From a22820a31c191451334eec101125f7b621d6dbc0 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 12 Feb 2018 20:02:36 +0200 Subject: [PATCH] Avoid aborts in cm.c due to too small TTY frame * src/frame.c (frame_windows_min_size): Limit TTY frames to a minimum height large enough to allow for a menu bar, the mode line, one text line and one echo-area line. This avoids aborts in cm.c:cmcheckmagic. (Bug#30320) --- src/frame.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/frame.c b/src/frame.c index d5b080d688a..a86f05191a8 100644 --- a/src/frame.c +++ b/src/frame.c @@ -341,7 +341,9 @@ DEFUN ("frame-windows-min-size", Fframe_windows_min_size, * of `window-min-height' (`window-min-width' if HORIZONTAL is non-nil). * With IGNORE non-nil the values of these variables are ignored. * - * In either case, never return a value less than 1. + * In either case, never return a value less than 1. For TTY frames, + * additionally limit the minimum frame height to a value large enough + * to support the menu bar, the mode line, and the echo area. */ static int frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, @@ -349,6 +351,7 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, { struct frame *f = XFRAME (frame); Lisp_Object par_size; + int retval; if ((!NILP (horizontal) && NUMBERP (par_size = get_frame_param (f, Qmin_width))) @@ -361,15 +364,27 @@ frame_windows_min_size (Lisp_Object frame, Lisp_Object horizontal, if (min_size < 1) min_size = 1; - return (NILP (pixelwise) - ? min_size - : min_size * (NILP (horizontal) - ? FRAME_LINE_HEIGHT (f) - : FRAME_COLUMN_WIDTH (f))); + retval = (NILP (pixelwise) + ? min_size + : min_size * (NILP (horizontal) + ? FRAME_LINE_HEIGHT (f) + : FRAME_COLUMN_WIDTH (f))); } else - return XINT (call4 (Qframe_windows_min_size, frame, horizontal, - ignore, pixelwise)); + retval = XINT (call4 (Qframe_windows_min_size, frame, horizontal, + ignore, pixelwise)); + /* Don't allow too small height of text-mode frames, or else cm.c + might abort in cmcheckmagic. */ + if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) && NILP (horizontal)) + { + int min_height = (FRAME_MENU_BAR_LINES (f) + + FRAME_WANTS_MODELINE_P (f) + + 2); /* one text line and one echo-area line */ + if (retval < min_height) + retval = min_height; + } + + return retval; } -- 2.39.2