From 9ca1ac62f9aa6e01afb3697cc4b966d085be9d3a Mon Sep 17 00:00:00 2001 From: SiIky Date: Sat, 17 Feb 2018 18:08:27 +0000 Subject: Print unknown_str in case of error func can return NULL in case of error, but no checking is done when printing, and unknown_str wasn't being used anywhere. --- slstatus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slstatus.c b/slstatus.c index 89a3268..19bc127 100644 --- a/slstatus.c +++ b/slstatus.c @@ -87,8 +87,10 @@ main(int argc, char *argv[]) status[0] = '\0'; for (i = len = 0; i < LEN(args); i++) { + const char * res = args[i].func(args[i].args); + res = (res == NULL) ? unknown_str : res; len += snprintf(status + len, sizeof(status) - len, - args[i].fmt, args[i].func(args[i].args)); + args[i].fmt, res); if (len >= sizeof(status)) { status[sizeof(status) - 1] = '\0'; -- cgit v1.2.3