[Python-checkins] [3.6] closes bpo-31532: Fix memory corruption due to allocator mix (GH-3679) (#3681)
Benjamin Peterson
webhook-mailer at python.org
Thu Sep 21 02:47:15 EDT 2017
https://github.com/python/cpython/commit/88d0663005d258526496d1f8ee0acb7103c69e80
commit: 88d0663005d258526496d1f8ee0acb7103c69e80
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2017年09月20日T23:47:12-07:00
summary:
[3.6] closes bpo-31532: Fix memory corruption due to allocator mix (GH-3679) (#3681)
Fix a memory corruption in getpath.c due to mixed memory allocators
between Py_GetPath() and Py_SetPath().
The fix use the Raw allocator to mimic the windows version.
This patch should be used from python3.6 to the current version
for more details, see the bug report and
https://github.com/pyinstaller/pyinstaller/issues/2812
(cherry picked from commit 3d1e2ab584ed0175592b5be2a0bc98dc1723776a)
files:
A Misc/NEWS.d/next/C API/2017-09-20-21-59-52.bpo-31532.s9Cw9_.rst
M Modules/getpath.c
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 00000000000..7451986846e
--- /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 0f916436c51..dd3387a9d77 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");
More information about the Python-checkins
mailing list