From def1fcb089d222cca44c016d976df38680539a0d Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Sat, 26 Feb 2011 21:35:27 +0300 Subject: pyldb: minor fixup, fix a memory leak Autobuild-User: Matthieu Patou Autobuild-Date: Sun Mar 20 12:13:50 CET 2011 on sn-devel-104 --- source4/lib/ldb/pyldb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index d14487ba02..5fcc5a64b6 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -85,6 +85,7 @@ static void py_ldb_control_dealloc(PyLdbControlObject *self) if (self->mem_ctx != NULL) { talloc_free(self->mem_ctx); } + self->data = NULL; self->ob_type->tp_free(self); } @@ -111,7 +112,6 @@ static PyObject *py_ldb_control_set_critical(PyLdbControlObject *self, PyObject static PyObject *py_ldb_control_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { char *data = NULL; - const char *array[2]; const char * const kwnames[] = { "ldb", "data", NULL }; struct ldb_control *parsed_controls; PyLdbControlObject *ret; @@ -148,7 +148,7 @@ static PyObject *py_ldb_control_new(PyTypeObject *type, PyObject *args, PyObject ret->mem_ctx = mem_ctx; - ret->data = talloc_steal(mem_ctx, parsed_controls); + ret->data = talloc_move(mem_ctx, &parsed_controls); if (ret->data == NULL) { Py_DECREF(ret); PyErr_NoMemory(); @@ -209,6 +209,7 @@ static PyObject *PyLdbControl_FromControl(struct ldb_control *control) ctrl = (PyLdbControlObject *)PyLdbControl.tp_alloc(&PyLdbControl, 0); if (ctrl == NULL) { + talloc_free(ctl_ctx); PyErr_NoMemory(); return NULL; } -- cgit