]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix ConvParam() of the ctypes module to handle paramfunc failure
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 22:27:12 +0000 (00:27 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 8 Jul 2013 22:27:12 +0000 (00:27 +0200)
(MemoryError).

Modules/_ctypes/callproc.c

index 701961150b4ad5ee42ea98a4a1fdb2036f437237..ead1c6f62accdb7e3ed080314ff78b9af035141e 100644 (file)
@@ -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;