=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/session.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- src/usr.bin/tmux/session.c 2016/10/19 08:17:11 1.69 +++ src/usr.bin/tmux/session.c 2016/10/19 09:22:07 1.70 @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.69 2016/10/19 08:17:11 nicm Exp $ */ +/* $OpenBSD: session.c,v 1.70 2016/10/19 09:22:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -337,6 +337,7 @@ xasprintf(cause, "index in use: %d", idx); return (NULL); } + wl->session = s; env = environ_create(); environ_copy(global_environ, env); @@ -373,6 +374,7 @@ xasprintf(cause, "index in use: %d", idx); return (NULL); } + wl->session = s; winlink_set_window(wl, w); notify_session_window("window-linked", s, w); @@ -409,8 +411,8 @@ { struct winlink *wl; - RB_FOREACH(wl, winlinks, &s->windows) { - if (wl->window == w) + TAILQ_FOREACH(wl, &w->winlinks, wentry) { + if (wl->session == s) return (1); } return (0); @@ -679,6 +681,7 @@ /* Link all the windows from the target. */ RB_FOREACH(wl, winlinks, ww) { wl2 = winlink_add(&s->windows, wl->idx); + wl2->session = s; winlink_set_window(wl2, wl->window); notify_session_window("window-linked", s, wl2->window); wl2->flags |= wl->flags & WINLINK_ALERTFLAGS; @@ -729,6 +732,7 @@ /* Go through the winlinks and assign new indexes. */ RB_FOREACH(wl, winlinks, &old_wins) { wl_new = winlink_add(&s->windows, new_idx); + wl_new->session = s; winlink_set_window(wl_new, wl->window); wl_new->flags |= wl->flags & WINLINK_ALERTFLAGS;