From 0c16676642a1cb41f889fac02351fc2509dbecaa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 17 Jun 2009 19:01:06 +0200 Subject: pyldb: Fix memory leak of LdbMessage's created from Python. --- source4/lib/ldb/pyldb.c | 10 +++++++--- 1 file 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; } -- cgit