diff options
| author | Paul Eggert | 2013-08-26 11:10:30 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-08-26 11:10:30 -0700 |
| commit | 1fc8eb33f5534cd3828d7cd15e95771a514dc589 (patch) | |
| tree | 93b9ac5d7ec1eda4ff3b59868e3fe9f0bae22a7f /src/termchar.h | |
| parent | f5adc984fbdc82def6edc297e88c3ee993c674ae (diff) | |
| download | emacs-1fc8eb33f5534cd3828d7cd15e95771a514dc589.tar.gz emacs-1fc8eb33f5534cd3828d7cd15e95771a514dc589.zip | |
Fix unlikely core dump in init_tty, and simplify terminfo case.
* term.c (init_tty) [TERMINFO]: Fix check for buffer overrun.
The old version incorrectly dumped core if malloc returned a
buffer containing only non-NUL bytes.
(init_tty): Do not allocate or free termcap buffers; the
struct does that for us now.
* termchar.h (TERMCAP_BUFFER_SIZE) [!TERMINFO]: New constant.
(struct tty_display_info): Define members termcap_term_buffer and
termcap_strings_buffer only if !TERMINFO, since terminfo doesn't
use them. Allocate them directly in struct rather than indirectly
via a pointer, to simplify init_tty.
Diffstat (limited to 'src/termchar.h')
| -rw-r--r-- | src/termchar.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/termchar.h b/src/termchar.h index 1c8e8646d4e..601b9fe8205 100644 --- a/src/termchar.h +++ b/src/termchar.h | |||
| @@ -28,6 +28,10 @@ struct tty_output | |||
| 28 | /* There is nothing else here at the moment... */ | 28 | /* There is nothing else here at the moment... */ |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | #ifndef TERMINFO | ||
| 32 | enum { TERMCAP_BUFFER_SIZE = 4096 }; | ||
| 33 | #endif | ||
| 34 | |||
| 31 | /* Parameters that are shared between frames on the same tty device. */ | 35 | /* Parameters that are shared between frames on the same tty device. */ |
| 32 | 36 | ||
| 33 | struct tty_display_info | 37 | struct tty_display_info |
| @@ -72,14 +76,15 @@ struct tty_display_info | |||
| 72 | mouse-face. */ | 76 | mouse-face. */ |
| 73 | Mouse_HLInfo mouse_highlight; | 77 | Mouse_HLInfo mouse_highlight; |
| 74 | 78 | ||
| 79 | #ifndef TERMINFO | ||
| 75 | /* Buffer used internally by termcap (see tgetent in the Termcap | 80 | /* Buffer used internally by termcap (see tgetent in the Termcap |
| 76 | manual). Only init_tty and delete_tty should change this. */ | 81 | manual). Only init_tty should use this. */ |
| 77 | char *termcap_term_buffer; | 82 | char termcap_term_buffer[TERMCAP_BUFFER_SIZE]; |
| 78 | 83 | ||
| 79 | /* Buffer storing terminal description strings (see tgetstr in the | 84 | /* Buffer storing terminal description strings (see tgetstr in the |
| 80 | Termcap manual). Only init_tty and delete_tty should change | 85 | Termcap manual). Only init_tty should use this. */ |
| 81 | this. */ | 86 | char termcap_strings_buffer[TERMCAP_BUFFER_SIZE]; |
| 82 | char *termcap_strings_buffer; | 87 | #endif |
| 83 | 88 | ||
| 84 | /* Strings, numbers and flags taken from the termcap entry. */ | 89 | /* Strings, numbers and flags taken from the termcap entry. */ |
| 85 | 90 | ||