diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2009-06-17 20:23:54 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2009-06-17 20:45:39 +0200 |
commit | 0c3769e181c09f45861f3b9f1d05cad8423372c3 (patch) | |
tree | 0dc278f8e0c7270464ffdca41e7f62f3f4582866 /source4/lib/ldb | |
parent | f1561cd72be1dd3c084dee3406973ffc5911da28 (diff) | |
download | samba-0c3769e181c09f45861f3b9f1d05cad8423372c3.tar.gz samba-0c3769e181c09f45861f3b9f1d05cad8423372c3.tar.bz2 samba-0c3769e181c09f45861f3b9f1d05cad8423372c3.zip |
pyldb: Fix memory leak in Dn.concat.
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/pyldb.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index deeddd11fd..0f666a35f3 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -291,11 +291,20 @@ static PyObject *py_ldb_dn_concat(PyLdbDnObject *self, PyObject *py_other) { struct ldb_dn *dn = PyLdbDn_AsDn((PyObject *)self), *other; - struct ldb_dn *ret = ldb_dn_copy(NULL, dn); + PyLdbDnObject *py_ret; + if (!PyObject_AsDn(NULL, py_other, NULL, &other)) return NULL; - ldb_dn_add_child(ret, other); - return PyLdbDn_FromDn(ret); + + py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0); + if (py_ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + py_ret->mem_ctx = talloc_new(NULL); + py_ret->dn = ldb_dn_copy(py_ret->mem_ctx, dn); + ldb_dn_add_child(py_ret->dn, other); + return (PyObject *)py_ret; } static PySequenceMethods py_ldb_dn_seq = { |