summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-03-03 22:29:08 +0100
committerAndrew Bartlett <abartlet@samba.org>2015-03-03 23:20:06 +0100
commitf87e6df34ac05b352c6c74bf1fd1d678ee23217f (patch)
treeff3b9e75a25d5df20f1c53a98a11d60f5a18840e /lib
parent92ff259f409cfeffc24ef9d7db8ab16217367bab (diff)
downloadsamba-f87e6df34ac05b352c6c74bf1fd1d678ee23217f.tar.gz
samba-f87e6df34ac05b352c6c74bf1fd1d678ee23217f.tar.xz
samba-f87e6df34ac05b352c6c74bf1fd1d678ee23217f.zip
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 <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/pyldb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 4f452fa5e7..9ee71eb73f 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();