summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-06-17 18:36:16 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-06-17 20:45:37 +0200
commitd558d8ab94874a6acc1ff0c843b47d5319099a84 (patch)
tree0905629038f804b3a2780dba1fdb2b6549f1a70f /source4
parentc3770f1dc0121cce0e17d64cf918ff425d1263f0 (diff)
downloadsamba-d558d8ab94874a6acc1ff0c843b47d5319099a84.tar.gz
samba-d558d8ab94874a6acc1ff0c843b47d5319099a84.tar.bz2
samba-d558d8ab94874a6acc1ff0c843b47d5319099a84.zip
pyldb: Fix two memory leaks of attribute lists.
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/pyldb.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 430dcd6182..ce38e06638 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -825,7 +825,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
if (py_attrs == Py_None) {
attrs = NULL;
} else {
- attrs = PyList_AsStringList(ldb_ctx, py_attrs, "attrs");
+ attrs = PyList_AsStringList(NULL, py_attrs, "attrs");
if (attrs == NULL)
return NULL;
}
@@ -833,8 +833,10 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
if (py_base == Py_None) {
base = ldb_get_default_basedn(ldb_ctx);
} else {
- if (!PyObject_AsDn(ldb_ctx, py_base, ldb_ctx, &base))
+ if (!PyObject_AsDn(ldb_ctx, py_base, ldb_ctx, &base)) {
+ talloc_free(attrs);
return NULL;
+ }
}
if (py_controls == Py_None) {
@@ -848,6 +850,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
res = talloc_zero(ldb_ctx, struct ldb_result);
if (res == NULL) {
PyErr_NoMemory();
+ talloc_free(attrs);
return NULL;
}
@@ -861,6 +864,8 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
ldb_search_default_callback,
NULL);
+ talloc_steal(req, attrs);
+
if (ret != LDB_SUCCESS) {
talloc_free(res);
PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, ldb_ctx);
@@ -1136,6 +1141,7 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P
struct ldb_request *req;
const char * const kwnames[] = { "base", "scope", "tree", "attrs", NULL };
struct ldb_module *mod;
+ const char * const*attrs;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiOO",
discard_const_p(char *, kwnames),
@@ -1144,9 +1150,20 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P
mod = self->mod;
+ if (py_attrs == Py_None) {
+ attrs = NULL;
+ } else {
+ attrs = PyList_AsStringList(NULL, py_attrs, "attrs");
+ if (attrs == NULL)
+ return NULL;
+ }
+
ret = ldb_build_search_req(&req, mod->ldb, NULL, PyLdbDn_AsDn(py_base),
- scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs, "attrs"),
+ scope, NULL /* expr */, attrs,
NULL /* controls */, NULL, NULL, NULL);
+
+ talloc_steal(req, attrs);
+
PyErr_LDB_ERROR_IS_ERR_RAISE(PyExc_LdbError, ret, mod->ldb);
req->op.search.res = NULL;