summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-12-25 23:44:37 +0000
committerTiago Cunha <tcunha@gmx.com>2010-12-25 23:44:37 +0000
commit3cd9ea1789a5af00b41b04617a83bcb25777922b (patch)
tree4c457d46351b81fb50132126ef5f3aaac21072e2
parent3585feca54dcd4b86426eb220507cb6c56ed045a (diff)
Sync OpenBSD patchset 808:
server_kill_window can modify the RB tree so don't use RB_FOREACH, fixes crash seen by Dan Harnett.
-rw-r--r--server-fn.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/server-fn.c b/server-fn.c
index d83520d9..6d556695 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -1,4 +1,4 @@
-/* $Id: server-fn.c,v 1.116 2010-12-22 15:36:44 tcunha Exp $ */
+/* $Id: server-fn.c,v 1.117 2010-12-25 23:44:37 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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) {