mirror of
https://github.com/python/cpython.git
synced 2026-06-21 18:41:52 -04:00
gh-151126: Fix crash on unset memory error in ctypes.get_errno (#151382)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Fix crash on unset :exc:`MemoryError` on allocation failure in
|
||||
:func:`ctypes.get_errno`.
|
||||
@@ -168,8 +168,9 @@ _ctypes_get_errobj(ctypes_state *st, int **pspace)
|
||||
}
|
||||
else {
|
||||
void *space = PyMem_Calloc(2, sizeof(int));
|
||||
if (space == NULL)
|
||||
return NULL;
|
||||
if (space == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
errobj = PyCapsule_New(space, CTYPES_CAPSULE_NAME_PYMEM, pymem_destructor);
|
||||
if (errobj == NULL) {
|
||||
PyMem_Free(space);
|
||||
|
||||
Reference in New Issue
Block a user