pyldb: minor fixup, fix a memory leak
authorMatthieu Patou <mat@matws.net>
Sat, 26 Feb 2011 18:35:27 +0000 (21:35 +0300)
committerMatthieu Patou <mat@samba.org>
Sun, 20 Mar 2011 11:13:50 +0000 (12:13 +0100)
Autobuild-User: Matthieu Patou <mat@samba.org>
Autobuild-Date: Sun Mar 20 12:13:50 CET 2011 on sn-devel-104

source4/lib/ldb/pyldb.c

index d14487ba02186daafc606c89f1e903d064025e78..5fcc5a64b692f6267f6aba0863f1a70d62a482c3 100644 (file)
@@ -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;
        }