s4/param/provision py_dom_sid_FromSid: avoid python memleak
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 2 May 2018 21:59:13 +0000 (09:59 +1200)
committerNoel Power <npower@samba.org>
Tue, 29 Jan 2019 15:54:48 +0000 (16:54 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Jan 29 16:54:48 CET 2019 on sn-devel-144

source4/param/provision.c

index 153850667b12742234d1987243cdc35b9da3fa4e..ee84cd021e1fa60828d6bad8f300e2e6ea9b503d 100644 (file)
@@ -199,13 +199,15 @@ static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
        PyObject *mod_security, *dom_sid_Type;
 
        mod_security = PyImport_ImportModule("samba.dcerpc.security");
-       if (mod_security == NULL)
+       if (mod_security == NULL) {
                return NULL;
-
+       }
        dom_sid_Type = PyObject_GetAttrString(mod_security, "dom_sid");
-       if (dom_sid_Type == NULL)
+       if (dom_sid_Type == NULL) {
+               Py_DECREF(mod_security);
                return NULL;
-
+       }
+       Py_DECREF(mod_security);
        return pytalloc_reference((PyTypeObject *)dom_sid_Type, sid);
 }