mirror of
https://github.com/python/cpython.git
synced 2026-06-27 19:36:07 +00:00
[3.15] gh-151126: Add missing PyErr_NoMemory in _winapi.c (GH-151588) (#152182)
gh-151126: Add missing `PyErr_NoMemory` in `_winapi.c` (GH-151588)
(cherry picked from commit a580029f11)
Co-authored-by: Ivy Xu <fakeshadow1337@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
parent
06506197c9
commit
d6fd5378e3
2 changed files with 6 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
Avoid possible crash in ``_winapi.c`` where a device has no memory left. Now
|
||||
it properly raises a :exc:`MemoryError`. Patch by Ivy Xu.
|
||||
|
|
@ -1677,6 +1677,9 @@ _winapi_GetShortPathName_impl(PyObject *module, LPCWSTR path)
|
|||
}
|
||||
PyMem_Free((void *)buffer);
|
||||
}
|
||||
else {
|
||||
PyErr_NoMemory();
|
||||
}
|
||||
} else {
|
||||
PyErr_SetFromWindowsErr(0);
|
||||
}
|
||||
|
|
@ -2387,6 +2390,7 @@ _winapi_BatchedWaitForMultipleObjects_impl(PyObject *module,
|
|||
while (i < nhandles) {
|
||||
BatchedWaitData *data = (BatchedWaitData*)PyMem_Malloc(sizeof(BatchedWaitData));
|
||||
if (!data) {
|
||||
PyErr_NoMemory();
|
||||
goto error;
|
||||
}
|
||||
thread_data[thread_count++] = data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue