diff options
| author | Eli Zaretskii | 2015-05-31 17:41:35 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2015-05-31 17:41:35 +0300 |
| commit | cab645a62f3e5963ee7da94eb9c33961601c6651 (patch) | |
| tree | bb09b6cf6ca9b103524201bcb7fc5947951613d9 /src | |
| parent | 643470ff797407b256eea380e0f41d3749400927 (diff) | |
| download | emacs-cab645a62f3e5963ee7da94eb9c33961601c6651.tar.gz emacs-cab645a62f3e5963ee7da94eb9c33961601c6651.zip | |
Attempt to fix crashes due to accesses beyond glyph matrix end
* src/xdisp.c (x_produce_glyphs): When it->ascent and it->descent
are determined from per-character metrics, don't let the
max_ascent and max_descent become smaller than values returned by
normal_char_ascent_descent, to avoid unpleasant dynamic resizing
of screen line heights when text changes.
* src/xterm.c (x_new_font)
* src/w32term.c (x_new_font): Call get_font_ascent_descent to
obtain a reasonable value for FRAME_LINE_HEIGHT, even when a font
claims very large value for its height.
* src/font.c (font_open_entity): Call get_font_ascent_descent to
obtain a reasonable value for FRAME_SMALLEST_FONT_HEIGHT, even
when a font claims very large value for its height.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 7 | ||||
| -rw-r--r-- | src/w32term.c | 5 | ||||
| -rw-r--r-- | src/xdisp.c | 16 | ||||
| -rw-r--r-- | src/xterm.c | 5 |
4 files changed, 28 insertions, 5 deletions
diff --git a/src/font.c b/src/font.c index 2ccfd15d436..903a0a6984b 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2908,7 +2908,12 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 2908 | : font->average_width ? font->average_width | 2908 | : font->average_width ? font->average_width |
| 2909 | : font->space_width ? font->space_width | 2909 | : font->space_width ? font->space_width |
| 2910 | : 1); | 2910 | : 1); |
| 2911 | height = (font->height ? font->height : 1); | 2911 | |
| 2912 | int font_ascent, font_descent; | ||
| 2913 | get_font_ascent_descent (font, &font_ascent, &font_descent); | ||
| 2914 | height = font_ascent + font_descent; | ||
| 2915 | if (height <= 0) | ||
| 2916 | height = 1; | ||
| 2912 | #ifdef HAVE_WINDOW_SYSTEM | 2917 | #ifdef HAVE_WINDOW_SYSTEM |
| 2913 | FRAME_DISPLAY_INFO (f)->n_fonts++; | 2918 | FRAME_DISPLAY_INFO (f)->n_fonts++; |
| 2914 | if (FRAME_DISPLAY_INFO (f)->n_fonts == 1) | 2919 | if (FRAME_DISPLAY_INFO (f)->n_fonts == 1) |
diff --git a/src/w32term.c b/src/w32term.c index 9c4f28fa2d4..b7c6e13c8a8 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -5832,7 +5832,7 @@ Lisp_Object | |||
| 5832 | x_new_font (struct frame *f, Lisp_Object font_object, int fontset) | 5832 | x_new_font (struct frame *f, Lisp_Object font_object, int fontset) |
| 5833 | { | 5833 | { |
| 5834 | struct font *font = XFONT_OBJECT (font_object); | 5834 | struct font *font = XFONT_OBJECT (font_object); |
| 5835 | int unit; | 5835 | int unit, font_ascent, font_descent; |
| 5836 | 5836 | ||
| 5837 | if (fontset < 0) | 5837 | if (fontset < 0) |
| 5838 | fontset = fontset_from_font (font_object); | 5838 | fontset = fontset_from_font (font_object); |
| @@ -5845,7 +5845,8 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) | |||
| 5845 | FRAME_FONT (f) = font; | 5845 | FRAME_FONT (f) = font; |
| 5846 | FRAME_BASELINE_OFFSET (f) = font->baseline_offset; | 5846 | FRAME_BASELINE_OFFSET (f) = font->baseline_offset; |
| 5847 | FRAME_COLUMN_WIDTH (f) = unit = font->average_width; | 5847 | FRAME_COLUMN_WIDTH (f) = unit = font->average_width; |
| 5848 | FRAME_LINE_HEIGHT (f) = font->height; | 5848 | get_font_ascent_descent (font, &font_ascent, &font_descent); |
| 5849 | FRAME_LINE_HEIGHT (f) = font_ascent + font_descent; | ||
| 5849 | 5850 | ||
| 5850 | /* Compute number of scrollbar columns. */ | 5851 | /* Compute number of scrollbar columns. */ |
| 5851 | unit = FRAME_COLUMN_WIDTH (f); | 5852 | unit = FRAME_COLUMN_WIDTH (f); |
diff --git a/src/xdisp.c b/src/xdisp.c index 53303272e60..ea9b05eabc4 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -26763,6 +26763,22 @@ x_produce_glyphs (struct it *it) | |||
| 26763 | it->nglyphs = 1; | 26763 | it->nglyphs = 1; |
| 26764 | } | 26764 | } |
| 26765 | } | 26765 | } |
| 26766 | |||
| 26767 | if (FONT_TOO_HIGH (font)) | ||
| 26768 | { | ||
| 26769 | int font_ascent, font_descent; | ||
| 26770 | |||
| 26771 | /* For very large fonts, where we ignore the declared font | ||
| 26772 | dimensions, and go by per-character metrics instead, | ||
| 26773 | don't let the row ascent and descent values (and the row | ||
| 26774 | height computed from them) be smaller than the "normal" | ||
| 26775 | character metrics. This avoids unpleasant effects | ||
| 26776 | whereby lines on display would change their heigh | ||
| 26777 | depending on which characters are shown. */ | ||
| 26778 | normal_char_ascent_descent (font, -1, &font_ascent, &font_descent); | ||
| 26779 | it->max_ascent = max (it->max_ascent, font_ascent); | ||
| 26780 | it->max_descent = max (it->max_descent, font_descent); | ||
| 26781 | } | ||
| 26766 | } | 26782 | } |
| 26767 | else if (it->what == IT_COMPOSITION && it->cmp_it.ch < 0) | 26783 | else if (it->what == IT_COMPOSITION && it->cmp_it.ch < 0) |
| 26768 | { | 26784 | { |
diff --git a/src/xterm.c b/src/xterm.c index 58563ff35d0..ac77d8083e0 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -9410,7 +9410,7 @@ Lisp_Object | |||
| 9410 | x_new_font (struct frame *f, Lisp_Object font_object, int fontset) | 9410 | x_new_font (struct frame *f, Lisp_Object font_object, int fontset) |
| 9411 | { | 9411 | { |
| 9412 | struct font *font = XFONT_OBJECT (font_object); | 9412 | struct font *font = XFONT_OBJECT (font_object); |
| 9413 | int unit; | 9413 | int unit, font_ascent, font_descent; |
| 9414 | 9414 | ||
| 9415 | if (fontset < 0) | 9415 | if (fontset < 0) |
| 9416 | fontset = fontset_from_font (font_object); | 9416 | fontset = fontset_from_font (font_object); |
| @@ -9423,7 +9423,8 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset) | |||
| 9423 | FRAME_FONT (f) = font; | 9423 | FRAME_FONT (f) = font; |
| 9424 | FRAME_BASELINE_OFFSET (f) = font->baseline_offset; | 9424 | FRAME_BASELINE_OFFSET (f) = font->baseline_offset; |
| 9425 | FRAME_COLUMN_WIDTH (f) = font->average_width; | 9425 | FRAME_COLUMN_WIDTH (f) = font->average_width; |
| 9426 | FRAME_LINE_HEIGHT (f) = FONT_HEIGHT (font); | 9426 | get_font_ascent_descent (font, &font_ascent, &font_descent); |
| 9427 | FRAME_LINE_HEIGHT (f) = font_ascent + font_descent; | ||
| 9427 | 9428 | ||
| 9428 | #ifndef USE_X_TOOLKIT | 9429 | #ifndef USE_X_TOOLKIT |
| 9429 | FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); | 9430 | FRAME_MENU_BAR_HEIGHT (f) = FRAME_MENU_BAR_LINES (f) * FRAME_LINE_HEIGHT (f); |