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)
This commit is contained in:
Eli Zaretskii 2018-02-12 20:02:36 +02:00
parent 26f64410fd
commit a22820a31c

View file

@ -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;
}