diff options
author | SiIky <siiky@users.noreply.github.com> | 2018-02-17 18:08:27 +0000 |
---|---|---|
committer | SiIky <siiky@users.noreply.github.com> | 2018-02-17 18:08:27 +0000 |
commit | 9ca1ac62f9aa6e01afb3697cc4b966d085be9d3a (patch) | |
tree | a037c1df6b3ca01f8f295488c622e74b66a300f5 /slstatus.c | |
parent | 8bfe4b2e280e4d4b9762d3a93c4ec94c2fc9d754 (diff) |
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.
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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'; |