Skip to content

Commit 3d1e2ab

Browse files
nurelinbenjaminp
authored andcommitted
bpo-31532: Fix memory corruption due to allocator mix (#3679)
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
1 parent b091bec commit 3d1e2ab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
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)