]> code.delx.au - gnu-emacs/commitdiff
Avoid division by zero crash observed by Yuan MEI.
authorMartin Rudalics <rudalics@gmx.at>
Fri, 6 Nov 2015 11:15:18 +0000 (12:15 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Fri, 6 Nov 2015 11:15:18 +0000 (12:15 +0100)
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
src/xterm.c

index 91640769838f09a5e2636d29a82365aa1c434bcb..1a822f0636504e959b4c3fd0b5bdbfae76691ba6 100644 (file)
@@ -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)
index 691ad05efe182f8a3a717b4be3bde4f2eb3b7b6f..5e9c16b8af42ccdb538caa63c94553070d17ea0e 100644 (file)
@@ -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);