]> granicus.if.org Git - python/commitdiff
Check for NULL return value of GenericCData_new().
authorThomas Heller <theller@ctypes.org>
Mon, 14 Aug 2006 07:50:14 +0000 (07:50 +0000)
committerThomas Heller <theller@ctypes.org>
Mon, 14 Aug 2006 07:50:14 +0000 (07:50 +0000)
Fixes klockwork issues #188, #189.

Modules/_ctypes/_ctypes.c

index 5f3d2ef12648da522f0977970fea57086937e395..d8726ec9f9888045ecb753a34df277cf38dfc914 100644 (file)
@@ -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;