Skip to content

Commit 88d0663

Browse files
miss-islingtonbenjaminp
authored andcommitted
[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 pyinstaller/pyinstaller#2812 (cherry picked from commit 3d1e2ab)
1 parent 6b44ad1 commit 88d0663

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix memory corruption due to allocator mix in getpath.c between Py_GetPath()
2+
and Py_SetPath()

Modules/getpath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ calculate_path(void)
735735
bufsz += wcslen(zip_path) + 1;
736736
bufsz += wcslen(exec_prefix) + 1;
737737

738-
buf = PyMem_New(wchar_t, bufsz);
738+
buf = PyMem_RawMalloc(bufsz * sizeof(wchar_t));
739739
if (buf == NULL) {
740740
Py_FatalError(
741741
"Not enough memory for dynamic PYTHONPATH");

0 commit comments

Comments
 (0)