summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-02-14 12:37:55 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-02-14 12:37:55 +0000
commitb816b766a7d4d976344812315862bd0ab62c1f1d (patch)
tree85ec9e21aeb983f205213443d4a12692deaac446 /usr.bin/tmux
parent7669c7aa396239d1a45901a27ba8d5d5575ec6cf (diff)
Check for NULL session and whatnot in status_replace, from Thomas Adam.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/status.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index ca8db145986..da68a95a5a5 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.108 2014/01/28 23:07:09 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.109 2014/02/14 12:37:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -445,11 +445,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
if (fmt == NULL)
return (xstrdup(""));
- if (s == NULL)
+ if (s == NULL && c != NULL)
s = c->session;
- if (wl == NULL)
+ if (wl == NULL && s != NULL)
wl = s->curw;
- if (wp == NULL)
+ if (wp == NULL && wl != NULL)
wp = wl->window->active;
len = strftime(in, sizeof in, fmt, localtime(&t));
@@ -472,10 +472,14 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
*optr = '\0';
ft = format_create();
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wp);
+ if (c != NULL)
+ format_client(ft, c);
+ if (s != NULL)
+ format_session(ft, s);
+ if (s != NULL && wl != NULL)
+ format_winlink(ft, s, wl);
+ if (wp != NULL)
+ format_window_pane(ft, wp);
expanded = format_expand(ft, out);
format_free(ft);
return (expanded);