pyldb: py_ldb_msg_elements uses PyErr_LDB_MESSAGE_OR_RAISE
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 15 Mar 2024 04:16:34 +0000 (17:16 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 05:13:32 +0000 (05:13 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index b0a0e94ef7cf2bc0b1b72abffbc24837b03db672..6691b8178461295bc06914ea5b6656cde5dbd34e 100644 (file)
@@ -3905,12 +3905,15 @@ static PyObject *py_ldb_msg_items(PyObject *self,
        return l;
 }
 
-static PyObject *py_ldb_msg_elements(PyLdbMessageObject *self,
+static PyObject *py_ldb_msg_elements(PyObject *self,
                PyObject *Py_UNUSED(ignored))
 {
-       struct ldb_message *msg = pyldb_Message_AsMessage(self);
        Py_ssize_t i = 0;
-       PyObject *l = PyList_New(msg->num_elements);
+       PyObject *l = NULL;
+       struct ldb_message *msg = NULL;
+       PyErr_LDB_MESSAGE_OR_RAISE(self, msg);
+
+       l = PyList_New(msg->num_elements);
        if (l == NULL) {
                return NULL;
        }