From 3255037b250e85d5714d4398f42b14681ee26d75 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Thu, 14 Jun 2012 21:35:30 +0300 Subject: bugfix: null dereference in removeclient() caused freezes -- fixes #9 this fixes freezes caused by clients opened in another empty desktop and closed without ever being focused. this possibly hides another bug, where new clients that spawn on other desktops that are not followed do not become the current clients. reports by djura-sans/kuraku, TheLemonMan, Shinryuu. ref: https://bbs.archlinux.org/viewtopic.php?id=132122&p=27 https://bbs.archlinux.org/viewtopic.php?pid=1116092#p1116092 --- monsterwm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'monsterwm.c') diff --git a/monsterwm.c b/monsterwm.c index 82d8db9..734a111 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -642,9 +642,9 @@ void quit(void) { /* remove the specified client * - * note, the removing client can be on any desktop, - * we must return back to the current focused desktop. - * if c was the previously focused, prevfocus must be updated + * note: the removing client can be on any desktop! + * we must always return back to the current focused desktop + * if c was ther prevfocus client, prevfocus must be updated * else if c was the current one, current must be updated. */ void removeclient(client *c) { client **p = NULL; @@ -653,7 +653,7 @@ void removeclient(client *c) { for (select_desktop(nd), p = &head; *p && !(found = *p == c); p = &(*p)->next); *p = c->next; if (c == prevfocus) prevfocus = prev_client(current); - if (c == current || !head->next) update_current(prevfocus); + if (c == current || (head && !head->next)) update_current(prevfocus); free(c); c = NULL; if (cd == nd -1) tile(); else select_desktop(cd); } -- cgit v1.3.1