summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-16 13:30:16 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-16 13:30:16 (GMT)
commitc36674a2c52ecb30e180b3bcced2b8c529cf72fb (patch)
treec9fac135fceb8ef3ccb154301e42283314967d0b /Modules
parentad524375af042a549d28ec252f3071a595b892b2 (diff)
downloadcpython-c36674a2c52ecb30e180b3bcced2b8c529cf72fb.zip
cpython-c36674a2c52ecb30e180b3bcced2b8c529cf72fb.tar.gz
cpython-c36674a2c52ecb30e180b3bcced2b8c529cf72fb.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 7e89878..65b20be 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1463,7 +1463,7 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
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 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
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 @@ win32_xstat_impl(const char *path, struct _Py_stat_struct *result,
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 @@ win32_xstat_impl_w(const wchar_t *path, struct _Py_stat_struct *result,
return -1;
code = win32_xstat_impl_w(target_path, result, FALSE);
- PyMem_Free(target_path);
+ PyMem_RawFree(target_path);
return code;
}
} else