From: Andrew Bartlett Date: Wed, 31 Jan 2024 04:26:45 +0000 (+1300) Subject: ldb/pyldb: Call Py_DECREF(list) on failure in PyLdbResult_FromResult() X-Git-Tag: tdb-1.4.11~1544 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbdecac5f89c672456940caa4eb526a30837ed6a;p=thirdparty%2Fsamba.git 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 Reviewed-by: Douglas Bagnall --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 982828549d5..059e0240c57 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -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; }