From f87e6df34ac05b352c6c74bf1fd1d678ee23217f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 3 Mar 2015 22:29:08 +0100 Subject: [PATCH] pyldb: Properly preallocate result control list The list was always allocated with size 1, so if there is more than 1 result control, the additional items would not be added in the list, and would become leaked references. Signed-off-by: Petr Viktorin Reviewed-by: Jelmer Vernooij Reviewed-by: Andrew Bartlett --- lib/ldb/pyldb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 4f452fa5e75..9ee71eb73fa 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -269,7 +269,11 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result) ret->msgs = list; if (result->controls) { - controls = PyList_New(1); + i = 0; + while (result->controls[i]) { + i++; + } + controls = PyList_New(i); if (controls == NULL) { Py_DECREF(ret); PyErr_NoMemory(); -- 2.11.4.GIT