gh-151126: Add missing `PyErr_NoMemory` in `_winapi.c` (GH-151588)
(cherry picked from commit
a580029f1168cf87707b157865b6a6b89a77b7ad)
Co-authored-by: Ivy Xu <fakeshadow1337@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
--- /dev/null
+Avoid possible crash in ``_winapi.c`` where a device has no memory left. Now
+it properly raises a :exc:`MemoryError`. Patch by Ivy Xu.
}
PyMem_Free((void *)buffer);
}
+ else {
+ PyErr_NoMemory();
+ }
} else {
PyErr_SetFromWindowsErr(0);
}
while (i < nhandles) {
BatchedWaitData *data = (BatchedWaitData*)PyMem_Malloc(sizeof(BatchedWaitData));
if (!data) {
+ PyErr_NoMemory();
goto error;
}
thread_data[thread_count++] = data;