mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
gh-151126: Fix crash on unset memory error in ctypes.get_errno (#151382)
This commit is contained in:
parent
c37599200f
commit
6b217ea90b
2 changed files with 5 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue