When calling pipe-pane outside of a client, we cannot expect the
status_replace() routines to happen to expand the given pipe-pane command
since there's no context for them without a client.  In doing that, we have
to also protect the other callers of the format_() routines to not pass NULL
values.
---
 status.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/status.c b/status.c
index ffc66ad..b66fece 100644
--- a/status.c
+++ b/status.c
@@ -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);
-- 
1.9.rc1


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to