From: Martin v. Löwis Date: Thu, 13 Nov 2003 07:42:13 +0000 (+0000) Subject: Patch #804543: strdup saved locales. X-Git-Tag: v2.3.3c1~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=604b120ca62c97c0ca57bdf25df552db82790804;p=thirdparty%2FPython%2Fcpython.git Patch #804543: strdup saved locales. --- diff --git a/Modules/readline.c b/Modules/readline.c index 64935c6efef7..1f1b32708721 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -590,7 +590,7 @@ static void setup_readline(void) { #ifdef SAVE_LOCALE - char *saved_locale = setlocale(LC_CTYPE, NULL); + char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); #endif using_history(); @@ -631,6 +631,7 @@ setup_readline(void) #ifdef SAVE_LOCALE setlocale(LC_CTYPE, saved_locale); /* Restore locale */ + free(saved_locale); #endif } diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 018400cb9208..d32c376209f3 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -235,7 +235,7 @@ Py_Initialize(void) initialized by other means. Also set the encoding of stdin and stdout if these are terminals. */ - saved_locale = setlocale(LC_CTYPE, NULL); + saved_locale = strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, ""); codeset = nl_langinfo(CODESET); if (codeset && *codeset) { @@ -250,6 +250,7 @@ Py_Initialize(void) } else codeset = NULL; setlocale(LC_CTYPE, saved_locale); + free(saved_locale); if (codeset) { sys_stream = PySys_GetObject("stdin");