summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2019-02-15 10:04:23 +0000
committerAndrew Bartlett <abartlet@samba.org>2019-02-21 04:09:19 +0100
commit5f9a5ef262b4700b47bfb931b6b096f56aa56b15 (patch)
treecf817347b35d08d8c13af59a22bcb82bf9c45f3b /source4/param
parent8c92702d152e16277b658be81496a60841a03e85 (diff)
downloadsamba-5f9a5ef262b4700b47bfb931b6b096f56aa56b15.tar.gz
s4/param: Fix provision_get_schema leaking python object
provision_get_schema returns a ldb_context object which is stored in a python object. As a result the parent python object is never decrefed and probably not released ever. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/provision.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/source4/param/provision.c b/source4/param/provision.c
index 47f296afcdd..85671f80b87 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -555,13 +555,9 @@ struct ldb_context *provision_get_schema(TALLOC_CTX *mem_ctx,
py_ldb = PyObject_GetAttrString(py_result, "ldb");
Py_DECREF(py_result);
ldb_result = pyldb_Ldb_AsLdbContext(py_ldb);
- /*
- * #TODO #FIXME There is a leak here !!!
- * Looks like ldb is a new object returned from schema_fn
- * We extract the ldb_ctx from that which rightly
- * will be destoryed when py_ldb is decremented.
- * Presently the ldb_context is returned (but the owning
- * object is leaked)
- */
+ if (talloc_reference(mem_ctx, ldb_result) == NULL) {
+ ldb_result = NULL;
+ }
+ Py_DECREF(py_ldb);
return ldb_result;
}