changeset: 100560:ae76a1046bb9 user: Victor Stinner date: Wed Mar 16 14:30:16 2016 +0100 files: Modules/posixmodule.c description: Fix usage of PyMem_Malloc() in os.stat() Issue #26563: Replace PyMem_Malloc() with PyMem_RawMalloc() in the Windows implementation of os.stat(), since the code is called without holding the GIL. diff -r 58644086c195 -r ae76a1046bb9 Modules/posixmodule.c --- a/Modules/posixmodule.c Wed Mar 16 12:12:53 2016 +0100 +++ b/Modules/posixmodule.c Wed Mar 16 14:30:16 2016 +0100 @@ -1463,7 +1463,7 @@ if(!buf_size) return FALSE; - buf = PyMem_New(wchar_t, buf_size+1); + buf = (wchar_t *)PyMem_RawMalloc((buf_size + 1) * sizeof(wchar_t)); if (!buf) { SetLastError(ERROR_OUTOFMEMORY); return FALSE; @@ -1473,12 +1473,12 @@ buf, buf_size, VOLUME_NAME_DOS); if(!result_length) { - PyMem_Free(buf); + PyMem_RawFree(buf); return FALSE; } if(!CloseHandle(hdl)) { - PyMem_Free(buf); + PyMem_RawFree(buf); return FALSE; } @@ -1563,7 +1563,7 @@ return -1; code = win32_xstat_impl_w(target_path, result, FALSE); - PyMem_Free(target_path); + PyMem_RawFree(target_path); return code; } } else @@ -1653,7 +1653,7 @@ return -1; code = win32_xstat_impl_w(target_path, result, FALSE); - PyMem_Free(target_path); + PyMem_RawFree(target_path); return code; } } else