From 40014fe9fd59b3332b3bec20c6973ef324192b7a Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Fri, 6 Nov 2015 12:15:18 +0100 Subject: [PATCH] Avoid division by zero crash observed by Yuan MEI. See http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00194.html. * src/dispnew.c (required_matrix_height, required_matrix_width): Avoid division by zero. * src/xterm.c (x_term_init): Init dpyinfo->smallest_font_height and dpyinfo->smallest_char_width to 1. --- src/dispnew.c | 6 ++++-- src/xterm.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dispnew.c b/src/dispnew.c index 91640769838..1a822f06365 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -1694,7 +1694,8 @@ required_matrix_height (struct window *w) if (FRAME_WINDOW_P (f)) { - int ch_height = FRAME_SMALLEST_FONT_HEIGHT (f); + /* http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00194.html */ + int ch_height = max (FRAME_SMALLEST_FONT_HEIGHT (f), 1); int window_pixel_height = window_box_height (w) + eabs (w->vscroll); return (((window_pixel_height + ch_height - 1) @@ -1720,7 +1721,8 @@ required_matrix_width (struct window *w) struct frame *f = XFRAME (w->frame); if (FRAME_WINDOW_P (f)) { - int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f); + /* http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00194.html */ + int ch_width = max (FRAME_SMALLEST_CHAR_WIDTH (f), 1); /* Compute number of glyphs needed in a glyph row. */ return (((WINDOW_PIXEL_WIDTH (w) + ch_width - 1) diff --git a/src/xterm.c b/src/xterm.c index 691ad05efe1..5e9c16b8af4 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -11963,6 +11963,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->display = dpy; dpyinfo->connection = ConnectionNumber (dpyinfo->display); + /* http://lists.gnu.org/archive/html/emacs-devel/2015-11/msg00194.html */ + dpyinfo->smallest_font_height = 1; + dpyinfo->smallest_char_width = 1; + /* Set the name of the terminal. */ terminal->name = xlispstrdup (display_name); -- 2.39.5