ldb/pyldb: Call Py_DECREF(list) on failure in PyLdbResult_FromResult()
authorAndrew Bartlett <abartlet@samba.org>
Wed, 31 Jan 2024 04:26:45 +0000 (17:26 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 3 Mar 2024 22:33:34 +0000 (22:33 +0000)
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>
lib/ldb/pyldb.c

index 982828549d578d0a1c462a48401829c0a4c71df8..059e0240c5711e65fa4b5b21b87bf3ca5b683eea 100644 (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;
        }