workspace: Don't crash on invalid argument to meta_workspace_index

Mitigates: https://gitlab.gnome.org/GNOME/mutter/-/issues/2559
Mitigates: https://bugs.debian.org/1024438
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2774>
This commit is contained in:
Simon McVittie 2022-12-18 15:54:55 +00:00 committed by Marge Bot
parent cb03b46a20
commit ecdd2aeb85

View File

@ -704,7 +704,10 @@ meta_workspace_index (MetaWorkspace *workspace)
{
int ret;
g_return_val_if_fail (META_IS_WORKSPACE (workspace), -1);
ret = g_list_index (workspace->manager->workspaces, workspace);
g_return_val_if_fail (ret >= 0, -1);
return ret;