summaryrefslogtreecommitdiffstats
path: root/server-fn.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-12-23 21:56:38 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-12-23 21:56:38 +0000
commitd3d25365f17b2e7c4244a345a39e8c48f067858a (patch)
treec0d17ea5e3730c51c973fa5d446e902210127885 /server-fn.c
parent6fd2b5b87fd5cfe839223253c8f85af49599b886 (diff)
server_kill_window can modify the RB tree so don't use RB_FOREACH, fixes
crash seen by Dan Harnett.
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/server-fn.c b/server-fn.c
index ada92b9a..03fa01d2 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -239,10 +239,14 @@ server_lock_client(struct client *c)
void
server_kill_window(struct window *w)
{
- struct session *s;
+ struct session *s, *next_s;
struct winlink *wl;
- RB_FOREACH(s, sessions, &sessions) {
+ next_s = RB_MIN(sessions, &sessions);
+ while (next_s != NULL) {
+ s = next_s;
+ next_s = RB_NEXT(sessions, &sessions, s);
+
if (session_has(s, w) == NULL)
continue;
while ((wl = winlink_find_by_window(&s->windows, w)) != NULL) {