]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #804543: strdup saved locales.
authorMartin v. Löwis <martin@v.loewis.de>
Thu, 13 Nov 2003 07:42:13 +0000 (07:42 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Thu, 13 Nov 2003 07:42:13 +0000 (07:42 +0000)
Modules/readline.c
Python/pythonrun.c

index 64935c6efef7684c28938cfb45c13d50ee3bf506..1f1b32708721586a0b317bdb3e11db5d3214a53a 100644 (file)
@@ -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
 }
 
index 018400cb9208d3e8f437e3a326e911f1ed372768..d32c376209f37590e31dc80aa6cb8ad63f64c6f1 100644 (file)
@@ -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");