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>
struct torture_dsdb_syntax *priv;
priv = talloc_get_type_abort(data, struct torture_dsdb_syntax);
+ talloc_unlink(priv, priv->ldb);
talloc_free(priv);
return true;
DEBUG(0,("Failed to attach schema from local provision using remote prefixMap."));
return WERR_INTERNAL_ERROR;
}
- talloc_free(schema_ldb);
+ talloc_unlink(s, schema_ldb);
}
cycle_before_switching = lpcfg_parm_long(s->lp_ctx, NULL,
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;
}