Mercurial > mplayer.hg
diff osdep/getch2-win.c @ 29290:ef46d5a66bb2
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.
author | reimar |
---|---|
date | Sun, 31 May 2009 13:00:51 +0000 |
parents | 0f1b5b68af32 |
children | 749c87b2c3e2 |
line wrap: on
line diff
--- a/osdep/getch2-win.c Sun May 31 12:48:53 2009 +0000 +++ b/osdep/getch2-win.c Sun May 31 13:00:51 2009 +0000 @@ -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 @@ char* get_term_charset(void) { - static char codepage[10]; + char codepage[10]; unsigned i, cpno = GetConsoleOutputCP(); if (!cpno) cpno = GetACP(); @@ -196,9 +197,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