summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/C API/2017-09-20-21-59-52.bpo-31532.s9Cw9_.rst2
-rw-r--r--Modules/getpath.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/C API/2017-09-20-21-59-52.bpo-31532.s9Cw9_.rst b/Misc/NEWS.d/next/C API/2017-09-20-21-59-52.bpo-31532.s9Cw9_.rst
new file mode 100644
index 0000000..7451986
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2017-09-20-21-59-52.bpo-31532.s9Cw9_.rst
@@ -0,0 +1,2 @@
+Fix memory corruption due to allocator mix in getpath.c between Py_GetPath()
+and Py_SetPath()
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 0f91643..dd3387a 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -735,7 +735,7 @@ calculate_path(void)
bufsz += wcslen(zip_path) + 1;
bufsz += wcslen(exec_prefix) + 1;
- buf = PyMem_New(wchar_t, bufsz);
+ buf = PyMem_RawMalloc(bufsz * sizeof(wchar_t));
if (buf == NULL) {
Py_FatalError(
"Not enough memory for dynamic PYTHONPATH");