Index: osdep/getch2-win.c =================================================================== --- osdep/getch2-win.c (revision 29289) +++ osdep/getch2-win.c (working copy) @@ -25,6 +25,7 @@ #include "config.h" #include +#include #include #include "keycodes.h" #include "input/input.h" @@ -185,9 +186,10 @@ { 0, NULL } }; +/* return a malloced string for a system charset */ char* get_term_charset(void) { - static char codepage[10]; + char codepage[10]; unsigned i, cpno = GetConsoleOutputCP(); if (!cpno) cpno = GetACP(); @@ -196,9 +198,9 @@ 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 Index: osdep/getch2.c =================================================================== --- osdep/getch2.c (revision 29289) +++ osdep/getch2.c (working copy) @@ -292,12 +292,13 @@ } #ifdef CONFIG_ICONV +/* return a malloced string for a system charset */ 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; Index: osdep/getch2-os2.c =================================================================== --- osdep/getch2-os2.c (revision 29289) +++ osdep/getch2-os2.c (working copy) @@ -26,6 +37,7 @@ #include #include +#include #include "config.h" #include "keycodes.h" @@ -183,13 +195,14 @@ } #ifdef CONFIG_ICONV +/* return a malloced string for a system charset */ 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