From 7d0b0b85bc9e31285db8ea42866547bc4fb35f23 Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 24 Jan 2016 22:45:34 +0100 Subject: [PATCH] Check that the window desktop index is in the valid range --- src/util/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/window.c b/src/util/window.c index 5947c8e..d44ec0a 100644 --- a/src/util/window.c +++ b/src/util/window.c @@ -109,7 +109,7 @@ gboolean window_is_hidden(Window win) int get_window_desktop(Window win) { if (!server.viewports) - return get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); + return MAX(0, MIN(server.num_desktops - 1, get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL))); int x, y, w, h; get_window_coordinates(win, &x, &y, &w, &h);