1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

pyldb: Check whether Python object is a list

If we’re going to call PyList_Size() on an object, we should be sure
that it is a list first.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2023-08-25 14:21:24 +12:00 committed by Andrew Bartlett
parent 7dc181757c
commit 93d37f8bfc

View File

@ -454,6 +454,11 @@ static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx,
if (obj == Py_None)
return NULL;
if (!PyList_Check(obj)) {
PyErr_SetString(PyExc_ValueError, "Expected list of LDB results");
return NULL;
}
res = talloc_zero(mem_ctx, struct ldb_result);
res->count = PyList_Size(obj);
res->msgs = talloc_array(res, struct ldb_message *, res->count);