diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-27 00:39:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-27 00:39:09 (GMT) |
commit | c588feeea94788e164286dbd757e34829a2eefb5 (patch) | |
tree | 4568eb715f50b0d45d3e7b9fd63b420b6e86ffe7 /Modules/python.c | |
parent | 739cf4e3e6d7370ab6ddfc96637218eadfe81a13 (diff) | |
download | cpython-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.c | 5 |
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); |