Skip to content

Commit 97d8cc5

Browse files
author
georg.brandl
committed
another instance of #804543: use strdup() when saving the result of setlocale() because it could be overwritten by subsequent setlocale()s.
git-svn-id: http://svn.python.org/projects/python/branches/py3k@70029 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2bfb7b9 commit 97d8cc5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Modules/python.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ main(int argc, char **argv)
3737
fprintf(stderr, "out of memory\n");
3838
return 1;
3939
}
40-
oldloc = setlocale(LC_ALL, NULL);
40+
oldloc = strdup(setlocale(LC_ALL, NULL));
4141
setlocale(LC_ALL, "");
4242
for (i = 0; i < argc; i++) {
4343
#ifdef HAVE_BROKEN_MBSTOWCS
@@ -67,6 +67,7 @@ main(int argc, char **argv)
6767
}
6868
}
6969
setlocale(LC_ALL, oldloc);
70+
free(oldloc);
7071
res = Py_Main(argc, argv_copy);
7172
for (i = 0; i < argc; i++) {
7273
PyMem_Free(argv_copy2[i]);

0 commit comments

Comments
 (0)