Commit 01464563 authored by Victor Stinner's avatar Victor Stinner

Issue #18408: Fix ConvParam() of the ctypes module to handle paramfunc failure

(MemoryError).
parent 8a2393a1
...@@ -620,6 +620,8 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) ...@@ -620,6 +620,8 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
assert(dict->paramfunc); assert(dict->paramfunc);
/* If it has an stgdict, it is a CDataObject */ /* If it has an stgdict, it is a CDataObject */
carg = dict->paramfunc((CDataObject *)obj); carg = dict->paramfunc((CDataObject *)obj);
if (carg == NULL)
return -1;
pa->ffi_type = carg->pffi_type; pa->ffi_type = carg->pffi_type;
memcpy(&pa->value, &carg->value, sizeof(pa->value)); memcpy(&pa->value, &carg->value, sizeof(pa->value));
pa->keep = (PyObject *)carg; pa->keep = (PyObject *)carg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment