diff options
author | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 14:55:16 -0800 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 14:55:16 -0800 |
commit | b53654b6dbfce8318a7d4d1cdaddca7a7fec194b (patch) | |
tree | 204df61b2fb23424603db767732db35a687529c6 /Programs/python.c | |
parent | e1ac7d87afad9c07ec25e5705bb135b71347b581 (diff) | |
parent | 2296b978597ce62ec2185b78a43811610af2c0ea (diff) | |
download | cpython-b53654b6dbfce8318a7d4d1cdaddca7a7fec194b.tar.gz |
Issue #29416: Prevent infinite loop in pathlib.Path.mkdir
Diffstat (limited to 'Programs/python.c')
-rw-r--r-- | Programs/python.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Programs/python.c b/Programs/python.c index 37b10b837e..a7afbc774b 100644 --- a/Programs/python.c +++ b/Programs/python.c @@ -24,6 +24,9 @@ main(int argc, char **argv) int i, res; char *oldloc; + /* Force malloc() allocator to bootstrap Python */ + (void)_PyMem_SetupAllocators("malloc"); + argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1)); if (!argv_copy || !argv_copy2) { @@ -62,7 +65,13 @@ main(int argc, char **argv) setlocale(LC_ALL, oldloc); PyMem_RawFree(oldloc); + res = Py_Main(argc, argv_copy); + + /* Force again malloc() allocator to release memory blocks allocated + before Py_Main() */ + (void)_PyMem_SetupAllocators("malloc"); + for (i = 0; i < argc; i++) { PyMem_RawFree(argv_copy2[i]); } |