From: Thomas Heller Date: Mon, 14 Aug 2006 07:50:14 +0000 (+0000) Subject: Check for NULL return value of GenericCData_new(). X-Git-Tag: v2.5c1~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dca703fbda6d96e97e3872796c1748ee1b6a08e6;p=python Check for NULL return value of GenericCData_new(). Fixes klockwork issues #188, #189. --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 5f3d2ef126..d8726ec9f9 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2752,6 +2752,8 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (ptr == NULL) return NULL; ob = (CDataObject *)GenericCData_new(type, args, kwds); + if (ob == NULL) + return NULL; *(void **)ob->b_ptr = ptr; return (PyObject *)ob; } @@ -2799,6 +2801,8 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; self = (CFuncPtrObject *)GenericCData_new(type, args, kwds); + if (self == NULL) + return NULL; Py_INCREF(callable); self->callable = callable;