From 3fea9df85a7d489b81e21a7a63f9e115de712d4c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 22 Sep 2010 15:35:36 -0700 Subject: s4-param: Check type when converting python object to lp_ctx, fix some memory leaks. --- source4/auth/pyauth.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/auth/pyauth.c') diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c index dff696334c..a66411bb4a 100644 --- a/source4/auth/pyauth.c +++ b/source4/auth/pyauth.c @@ -46,12 +46,14 @@ static PyObject *py_system_session(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx)) return NULL; - lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: Leaks memory */ + lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); if (lp_ctx == NULL) return NULL; session = system_session(lp_ctx); + talloc_free(lp_ctx); + return PyAuthSession_FromSession(session); } @@ -66,13 +68,15 @@ static PyObject *py_admin_session(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "OO", &py_lp_ctx, &py_sid)) return NULL; - lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */ + lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); if (lp_ctx == NULL) return NULL; domain_sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid)); session = admin_session(NULL, lp_ctx, domain_sid); + talloc_free(lp_ctx); + return PyAuthSession_FromSession(session); } -- cgit