From d0accdba884517c55a842dec59ef2c8db6c208b5 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 12:37:54 +0000 Subject: Check for NULL session and whatnot in status_replace, from Thomas Adam. --- status.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'status.c') diff --git a/status.c b/status.c index e14c1a81..6966aadf 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); -- cgit From f835be4bb25f629613bbb7e0195a5c4fb12abf3e Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 13:59:01 +0000 Subject: Style nit - no space between function name and bracket. --- status.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'status.c') diff --git a/status.c b/status.c index 6966aadf..84589427 100644 --- a/status.c +++ b/status.c @@ -690,7 +690,7 @@ status_message_set(struct client *c, const char *fmt, ...) tv.tv_sec = delay / 1000; tv.tv_usec = (delay % 1000) * 1000L; - if (event_initialized (&c->message_timer)) + if (event_initialized(&c->message_timer)) evtimer_del(&c->message_timer); evtimer_set(&c->message_timer, status_message_callback, c); evtimer_add(&c->message_timer, &tv); -- cgit