From 28a2c262acf47a4a1f170375ea5e709a31a61ff4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 17 Jun 2009 19:07:44 +0200 Subject: param/python: Fix memory leak of LoadParm objects. --- source4/param/pyparam.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/param') diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 4f6e2fff49..8786ab67bb 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -295,7 +295,18 @@ static PyGetSetDef py_lp_ctx_getset[] = { static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - return py_talloc_import(type, loadparm_init(NULL)); + py_talloc_Object *ret = (py_talloc_Object *)type->tp_alloc(type, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->talloc_ctx = talloc_new(NULL); + if (ret->talloc_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->ptr = loadparm_init(ret->talloc_ctx); + return (PyObject *)ret; } static Py_ssize_t py_lp_ctx_len(py_talloc_Object *self) -- cgit