From 0fa5a77f46fb8a5ce06b93c0064e3ae4ea64084d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur?= Date: Wed, 6 Mar 2019 14:08:40 +0000 Subject: pytalloc: Check for errors during module initialization. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristján Valur Reviewed-by: Noel Power Reviewed-by: Andrew Bartlett --- lib/talloc/pytalloc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 95dbb297a46..ad3ad969a0f 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -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 -- cgit v1.2.1