summaryrefslogtreecommitdiffstats
path: root/Modules/python.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-27 00:39:09 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-27 00:39:09 (GMT)
commitc588feeea94788e164286dbd757e34829a2eefb5 (patch)
tree4568eb715f50b0d45d3e7b9fd63b420b6e86ffe7 /Modules/python.c
parent739cf4e3e6d7370ab6ddfc96637218eadfe81a13 (diff)
downloadcpython-c588feeea94788e164286dbd757e34829a2eefb5.zip
cpython-c588feeea94788e164286dbd757e34829a2eefb5.tar.gz
cpython-c588feeea94788e164286dbd757e34829a2eefb5.tar.bz2
Issue #15893: Improve error handling in main() and Py_FrozenMain()
* handle _PyMem_RawStrdup() failure * Py_FrozenMain() releases memory on error * Py_FrozenMain() duplicates the old locale, as done in main()
Diffstat (limited to 'Modules/python.c')
-rw-r--r--Modules/python.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/python.c b/Modules/python.c
index 326aa36..9811c01 100644
--- a/Modules/python.c
+++ b/Modules/python.c
@@ -45,6 +45,11 @@ main(int argc, char **argv)
#endif
oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
+ if (!oldloc) {
+ fprintf(stderr, "out of memory\n");
+ return 1;
+ }
+
setlocale(LC_ALL, "");
for (i = 0; i < argc; i++) {
argv_copy[i] = _Py_char2wchar(argv[i], NULL);