From 3f15cf0961946702c87e09bc312b2bfec39654b6 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 9 Jul 2013 00:27:12 +0200 Subject: [PATCH] Issue #18408: Fix ConvParam() of the ctypes module to handle paramfunc failure (MemoryError). --- Modules/_ctypes/callproc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 701961150b..ead1c6f62a 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -620,6 +620,8 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) assert(dict->paramfunc); /* If it has an stgdict, it is a CDataObject */ carg = dict->paramfunc((CDataObject *)obj); + if (carg == NULL) + return -1; pa->ffi_type = carg->pffi_type; memcpy(&pa->value, &carg->value, sizeof(pa->value)); pa->keep = (PyObject *)carg; -- 2.50.1