summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Franco (Kovensky) <diogomfranco@gmail.com>2013-07-26 16:03:56 -0300
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2013-07-26 16:03:56 -0300
commitfac2d9097ef9e022e50917ac3d8a20a6748d69b8 (patch)
tree02db5a0bfa23338cf0dc30fb80d49d9d5d9ce322
parent630edc0637a74e86c71bd4830793a2b50b91481b (diff)
downloadmpv-fac2d9097ef9e022e50917ac3d8a20a6748d69b8.tar.bz2
mpv-fac2d9097ef9e022e50917ac3d8a20a6748d69b8.tar.xz
getch2: Load the "ce", "ks" and "ke" caps into a static buffer
Fixes reports of printing of garbage (or anything else) other than clearing the status line to the end of line: the buffer returned by termcap_get could get moved, and if that happened then these 3 caps pointed to garbage.
-rw-r--r--osdep/getch2.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c
index 091f000cda..d31bb97ab0 100644
--- a/osdep/getch2.c
+++ b/osdep/getch2.c
@@ -270,7 +270,10 @@ int load_termcap(char *termtype){
#endif
ensure_cap(&termcap_buf, 2048);
- erase_to_end_of_line = termcap_get("ce");
+ static char term_buf[64];
+ char *buf_ptr = &term_buf[0];
+
+ erase_to_end_of_line = tgetstr("ce", &buf_ptr);
screen_width = tgetnum("co");
screen_height = tgetnum("li");
@@ -279,8 +282,8 @@ int load_termcap(char *termtype){
if (screen_height < 1 || screen_height > 255)
screen_height = 24;
- term_smkx = termcap_get("ks");
- term_rmkx = termcap_get("ke");
+ term_smkx = tgetstr("ks", &buf_ptr);
+ term_rmkx = tgetstr("ke", &buf_ptr);
cap_key_pair keys[] = {
{"kP", MP_KEY_PGUP}, {"kN", MP_KEY_PGDWN}, {"kh", MP_KEY_HOME}, {"kH", MP_KEY_END},