pytalloc: Check for errors during module initialization.
authorKristján Valur <kristjan@rvx.is>
Wed, 6 Mar 2019 14:08:40 +0000 (14:08 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 26 Mar 2019 03:03:23 +0000 (03:03 +0000)
Signed-off-by: Kristján Valur <kristjan@rvx.is>
Reviewed-by: Noel Power <npower@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/talloc/pytalloc.c

index 95dbb297a4606f144f5eacb84fe0911e98cfe5c1..ad3ad969a0f42da9af977b788a1a054b3f444e68 100644 (file)
@@ -281,12 +281,22 @@ static PyObject *module_init(void)
                return NULL;
 
        Py_INCREF(&TallocObject_Type);
-       PyModule_AddObject(m, "Object", (PyObject *)&TallocObject_Type);
+       if (PyModule_AddObject(m, "Object", (PyObject *)&TallocObject_Type)) {
+               goto err;
+       }
        Py_INCREF(&TallocBaseObject_Type);
-       PyModule_AddObject(m, "BaseObject", (PyObject *)&TallocBaseObject_Type);
+       if (PyModule_AddObject(m, "BaseObject", (PyObject *)&TallocBaseObject_Type)) {
+               goto err;
+       }
        Py_INCREF(&TallocGenericObject_Type);
-       PyModule_AddObject(m, "GenericObject", (PyObject *)&TallocGenericObject_Type);
+       if (PyModule_AddObject(m, "GenericObject", (PyObject *)&TallocGenericObject_Type)) {
+               goto err;
+       }
        return m;
+
+err:
+       Py_DECREF(m);
+       return NULL;
 }
 
 #if PY_MAJOR_VERSION >= 3