From: Georg Brandl Date: Fri, 27 Feb 2009 17:52:38 +0000 (+0000) Subject: another instance of #804543: use strdup() when saving the result of setlocale() becau... X-Git-Tag: v3.1a1~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26338d1cfd056b353f87697e418003d63ac1c42f;p=python another instance of #804543: use strdup() when saving the result of setlocale() because it could be overwritten by subsequent setlocale()s. --- diff --git a/Modules/python.c b/Modules/python.c index 9e7888999f..f6da86f1d6 100644 --- a/Modules/python.c +++ b/Modules/python.c @@ -37,7 +37,7 @@ main(int argc, char **argv) fprintf(stderr, "out of memory\n"); return 1; } - oldloc = setlocale(LC_ALL, NULL); + oldloc = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, ""); for (i = 0; i < argc; i++) { #ifdef HAVE_BROKEN_MBSTOWCS @@ -67,6 +67,7 @@ main(int argc, char **argv) } } setlocale(LC_ALL, oldloc); + free(oldloc); res = Py_Main(argc, argv_copy); for (i = 0; i < argc; i++) { PyMem_Free(argv_copy2[i]);