summaryrefslogtreecommitdiff
path: root/src/termchar.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-08-26 11:10:30 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-08-26 11:10:30 -0700
commit1fc8eb33f5534cd3828d7cd15e95771a514dc589 (patch)
tree93b9ac5d7ec1eda4ff3b59868e3fe9f0bae22a7f /src/termchar.h
parentf5adc984fbdc82def6edc297e88c3ee993c674ae (diff)
downloademacs-1fc8eb33f5534cd3828d7cd15e95771a514dc589.tar.gz
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.h15
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
/* There is nothing else here at the moment... */
};
+#ifndef TERMINFO
+enum { TERMCAP_BUFFER_SIZE = 4096 };
+#endif
+
/* Parameters that are shared between frames on the same tty device. */
struct tty_display_info
@@ -72,14 +76,15 @@ struct tty_display_info
mouse-face. */
Mouse_HLInfo mouse_highlight;
+#ifndef TERMINFO
/* Buffer used internally by termcap (see tgetent in the Termcap
- manual). Only init_tty and delete_tty should change this. */
- char *termcap_term_buffer;
+ manual). Only init_tty should use this. */
+ char termcap_term_buffer[TERMCAP_BUFFER_SIZE];
/* Buffer storing terminal description strings (see tgetstr in the
- Termcap manual). Only init_tty and delete_tty should change
- this. */
- char *termcap_strings_buffer;
+ Termcap manual). Only init_tty should use this. */
+ char termcap_strings_buffer[TERMCAP_BUFFER_SIZE];
+#endif
/* Strings, numbers and flags taken from the termcap entry. */