summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-03-31 21:41:08 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-03-31 21:41:08 +0000
commit8765f5d395c94852042ba6b88499d1c55a43c045 (patch)
tree33d6dae04ab0c3e1bd92396d5cc4f31a7bc34c4c /usr.bin/tmux/window.c
parent2c5c3924c53bcf9d8685dff07904a8cbee8ed070 (diff)
Don't segfaut when the parent of the layout cell is NULL, from Thomas Adam.
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r--usr.bin/tmux/window.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 094e1cf85bb..2892acb9fd6 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.102 2014/02/22 18:01:10 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.103 2014/03/31 21:41:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -423,10 +423,15 @@ window_pane_active_set(struct window_pane *wp, struct window_pane *nextwp)
void
window_pane_active_lost(struct window_pane *wp, struct window_pane *nextwp)
{
- struct layout_cell *lc, *lc2;
+ struct layout_cell *lc, *lc2, *lcparent;
+
+ /* Get the parent cell. */
+ lcparent = nextwp->layout_cell->parent;
+ if (lcparent == NULL)
+ return;
/* Save the target pane in its parent. */
- nextwp->layout_cell->parent->lastwp = nextwp;
+ lcparent->lastwp = nextwp;
/*
* Save the source pane in all of its parents up to, but not including,
@@ -435,8 +440,7 @@ window_pane_active_lost(struct window_pane *wp, struct window_pane *nextwp)
if (wp == NULL)
return;
for (lc = wp->layout_cell->parent; lc != NULL; lc = lc->parent) {
- lc2 = nextwp->layout_cell->parent;
- for (; lc2 != NULL; lc2 = lc2->parent) {
+ for (lc2 = lcparent; lc2 != NULL; lc2 = lc2->parent) {
if (lc == lc2)
return;
}