Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f15cf0

Browse files
committed
Issue #18408: Fix ConvParam() of the ctypes module to handle paramfunc failure
(MemoryError).
1 parent 78094ac commit 3f15cf0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Modules/_ctypes/callproc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
620620
assert(dict->paramfunc);
621621
/* If it has an stgdict, it is a CDataObject */
622622
carg = dict->paramfunc((CDataObject *)obj);
623+
if (carg == NULL)
624+
return -1;
623625
pa->ffi_type = carg->pffi_type;
624626
memcpy(&pa->value, &carg->value, sizeof(pa->value));
625627
pa->keep = (PyObject *)carg;

0 commit comments

Comments
 (0)