summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-06-17 20:32:35 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-17 20:45:39 +0200
commit4d2baca7be36d7cccbb2c632598a4e43ca1dd55e (patch)
tree60d8ac43e93cc479094d4dab147ec44a25560baa /source4/lib/ldb
parent0c3769e181c09f45861f3b9f1d05cad8423372c3 (diff)
downloadsamba-4d2baca7be36d7cccbb2c632598a4e43ca1dd55e.tar.gz
samba-4d2baca7be36d7cccbb2c632598a4e43ca1dd55e.tar.bz2
samba-4d2baca7be36d7cccbb2c632598a4e43ca1dd55e.zip
pyldb: Fix memory leak in Dn.get_parent().
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/pyldb.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 0f666a35f3..13706807be 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -207,10 +207,24 @@ static PyObject *py_ldb_dn_get_parent(PyLdbDnObject *self)
{
struct ldb_dn *dn = PyLdbDn_AsDn((PyObject *)self);
struct ldb_dn *parent;
+ PyLdbDnObject *py_ret;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
- parent = ldb_dn_get_parent(NULL, dn);
+ parent = ldb_dn_get_parent(mem_ctx, dn);
+ if (parent == NULL) {
+ talloc_free(mem_ctx);
+ Py_RETURN_NONE;
+ }
- return PyLdbDn_FromDn(parent);
+ py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0);
+ if (py_ret == NULL) {
+ PyErr_NoMemory();
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+ py_ret->mem_ctx = mem_ctx;
+ py_ret->dn = parent;
+ return (PyObject *)py_ret;
}
#define dn_ldb_ctx(dn) ((struct ldb_context *)dn)