diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-05-31 13:00:51 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-05-31 13:00:51 +0000 |
commit | 71fefd86ac7e2328ad11a8a3a49452a2e65b186b (patch) | |
tree | e0020c9481e406e4e4f0db4c9809c820ebe954a0 /osdep/getch2-win.c | |
parent | 960285ea46a70897c3baa4f0f6a33893caacbb16 (diff) | |
download | mpv-71fefd86ac7e2328ad11a8a3a49452a2e65b186b.tar.bz2 mpv-71fefd86ac7e2328ad11a8a3a49452a2e65b186b.tar.xz |
Use a malloced string for the get_term_charset return value.
This is necessary at least on POSIX systems since the buffer returned by
nl_langinfo may change its contents with e.g. each setlocale call.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29332 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'osdep/getch2-win.c')
-rw-r--r-- | osdep/getch2-win.c | 7 |
1 files changed, 4 insertions, 3 deletions
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 |