summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-06-17 19:01:06 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-17 20:45:38 +0200
commit0c16676642a1cb41f889fac02351fc2509dbecaa (patch)
tree0955a5fb977b1d4ee16aeb69be3a2bdb2f34ef5f /source4
parentd4172bbcc579fd446c252f2d7465275e3ee016b1 (diff)
downloadsamba-0c16676642a1cb41f889fac02351fc2509dbecaa.tar.gz
samba-0c16676642a1cb41f889fac02351fc2509dbecaa.tar.bz2
samba-0c16676642a1cb41f889fac02351fc2509dbecaa.zip
pyldb: Fix memory leak of LdbMessage's created from Python.
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/pyldb.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index ce38e06638..8e7ba4df90 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1677,18 +1677,22 @@ static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kw
return NULL;
}
- if (pydn != NULL)
- if (!PyObject_AsDn(NULL, pydn, NULL, &ret->dn))
+ if (pydn != NULL) {
+ if (!PyObject_AsDn(NULL, pydn, NULL, &ret->dn)) {
+ talloc_free(ret);
return NULL;
+ }
+ }
py_ret = (PyLdbMessageObject *)type->tp_alloc(type, 0);
if (py_ret == NULL) {
PyErr_NoMemory();
+ talloc_free(ret);
return NULL;
}
py_ret->mem_ctx = talloc_new(NULL);
- py_ret->msg = talloc_reference(py_ret->mem_ctx, ret);
+ py_ret->msg = talloc_steal(py_ret->mem_ctx, ret);
return (PyObject *)py_ret;
}