aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>2003-08-19 23:47:31 +0000
committerRichard M. Stallman <[email protected]>2003-08-19 23:47:31 +0000
commit3a06a6d99b0c573779862bd2b8fb7e56e8b16ccb (patch)
treeecf1d4074600c01efa2e714bd598bd613e609707
parent5851666e1007460793baf66ec5766dbe5c097e52 (diff)
(term_init): Use a buffer of size 4096 for tgetent since
FreeBSD returns something longer than 2044. Abort if the end of the buffer is overwritten.
-rw-r--r--src/ChangeLog9
-rw-r--r--src/term.c19
2 files changed, 18 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2d69bcf912..bdf4541154 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-19 Gerd Moellmann <[email protected]>
+
+ * s/freebsd.h [__FreeBSD_version >= 400000]: Define TERMINFO,
+ use -lncurses.
+
+ * term.c (term_init): Use a buffer of size 4096 for tgetent since
+ FreeBSD returns something longer than 2044. Abort if the end of
+ the buffer is overwritten.
+
2003-08-19 Miles Bader <[email protected]>
* xterm.c (x_term_init): Correctly use result of Ffile_readable_p.
diff --git a/src/term.c b/src/term.c
index 829f2d88e6..66232ab204 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2159,7 +2159,8 @@ term_init (terminal_type)
{
char *area;
char **address = &area;
- char buffer[2044];
+ char *buffer = NULL;
+ const int buffer_size = 4096;
register char *p;
int status;
struct frame *sf = XFRAME (selected_frame);
@@ -2171,9 +2172,6 @@ term_init (terminal_type)
area = (char *) xmalloc (2044);
- if (area == 0)
- abort ();
-
FrameRows = FRAME_LINES (sf);
FrameCols = FRAME_COLS (sf);
specified_window = FRAME_LINES (sf);
@@ -2202,6 +2200,7 @@ term_init (terminal_type)
Wcm_clear ();
+ buffer = (char *) xmalloc (buffer_size);
status = tgetent (buffer, terminal_type);
if (status < 0)
{
@@ -2229,13 +2228,11 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
terminal_type);
#endif
}
-#ifdef TERMINFO
- area = (char *) xmalloc (2044);
-#else
- area = (char *) xmalloc (strlen (buffer));
-#endif /* not TERMINFO */
- if (area == 0)
+
+ if (strlen (buffer) >= buffer_size)
abort ();
+
+ area = (char *) xmalloc (strlen (buffer));
TS_ins_line = tgetstr ("al", address);
TS_ins_multi_lines = tgetstr ("AL", address);
@@ -2560,6 +2557,8 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
#endif /* WINDOWSNT */
+
+ xfree (buffer);
}
/* VARARGS 1 */