ldb: Check result of py_ldb_msg_keys()
authorJo Sutton <josutton@catalyst.net.nz>
Thu, 18 Apr 2024 00:47:28 +0000 (12:47 +1200)
committerJo Sutton <jsutton@samba.org>
Sun, 21 Apr 2024 22:10:35 +0000 (22:10 +0000)
Passing NULL into PyObject_GetIter() can cause a segmentation fault.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index f416bfe6d5d70551f1c3d04c4abc4e8e398e9429..d54a952ac011138115035c414d1655f2f2caac52 100644 (file)
@@ -4143,6 +4143,9 @@ static PyObject *py_ldb_msg_iter(PyObject *self)
        PyObject *list, *iter;
 
        list = py_ldb_msg_keys(self, NULL);
+       if (list == NULL) {
+               return NULL;
+       }
        iter = PyObject_GetIter(list);
        Py_DECREF(list);
        return iter;