summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
Diffstat (limited to 'osdep')
-rw-r--r--osdep/getch2-os2.c3
-rw-r--r--osdep/getch2-win.c7
-rw-r--r--osdep/getch2.c2
3 files changed, 7 insertions, 5 deletions
diff --git a/osdep/getch2-os2.c b/osdep/getch2-os2.c
index abb7f2e6ac..272d2d45e9 100644
--- a/osdep/getch2-os2.c
+++ b/osdep/getch2-os2.c
@@ -26,6 +26,7 @@
#include <os2.h>
#include <stdio.h>
+#include <string.h>
#include "config.h"
#include "keycodes.h"
@@ -189,7 +190,7 @@ char *get_term_charset( void )
#ifdef HAVE_LANGINFO
setlocale( LC_CTYPE, "");
- charset = nl_langinfo( CODESET );
+ charset = strdup( nl_langinfo( CODESET ));
setlocale( LC_CTYPE, "C");
#endif
diff --git a/osdep/getch2-win.c b/osdep/getch2-win.c
index b201a9d6df..3c428834ff 100644
--- a/osdep/getch2-win.c
+++ b/osdep/getch2-win.c
@@ -25,6 +25,7 @@
#include "config.h"
#include <stdio.h>
+#include <string.h>
#include <windows.h>
#include "keycodes.h"
#include "input/input.h"
@@ -187,7 +188,7 @@ static const struct {
char* get_term_charset(void)
{
- static char codepage[10];
+ char codepage[10];
unsigned i, cpno = GetConsoleOutputCP();
if (!cpno)
cpno = GetACP();
@@ -196,9 +197,9 @@ char* get_term_charset(void)
for (i = 0; cp_alias[i].cp; i++)
if (cpno == cp_alias[i].cp)
- return cp_alias[i].alias;
+ return strdup(cp_alias[i].alias);
snprintf(codepage, sizeof(codepage), "CP%u", cpno);
- return codepage;
+ return strdup(codepage);
}
#endif
diff --git a/osdep/getch2.c b/osdep/getch2.c
index 2283bed648..4a591da2db 100644
--- a/osdep/getch2.c
+++ b/osdep/getch2.c
@@ -297,7 +297,7 @@ char* get_term_charset(void)
char* charset = NULL;
#ifdef HAVE_LANGINFO
setlocale(LC_CTYPE, "");
- charset = nl_langinfo(CODESET);
+ charset = strdup(nl_langinfo(CODESET));
setlocale(LC_CTYPE, "C");
#endif
return charset;