1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

ldb/pyldb: Call Py_DECREF(list) on failure in PyLdbResult_FromResult()

We need to drop the reference to the list we created if we
are going to fail.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2024-01-31 17:26:45 +13:00
parent 53cdfff711
commit dbdecac5f8

View File

@ -408,6 +408,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
controls = PyList_New(i);
if (controls == NULL) {
Py_DECREF(ret);
Py_DECREF(list);
PyErr_NoMemory();
return NULL;
}
@ -415,6 +416,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
PyObject *ctrl = (PyObject*) PyLdbControl_FromControl(result->controls[i]);
if (ctrl == NULL) {
Py_DECREF(ret);
Py_DECREF(list);
Py_DECREF(controls);
PyErr_NoMemory();
return NULL;
@ -428,6 +430,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
controls = PyList_New(0);
if (controls == NULL) {
Py_DECREF(ret);
Py_DECREF(list);
PyErr_NoMemory();
return NULL;
}
@ -444,6 +447,7 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
referals = PyList_New(i);
if (referals == NULL) {
Py_DECREF(ret);
Py_DECREF(list);
PyErr_NoMemory();
return NULL;
}