[hackers] [slstatus] Print unknown_str in case of error || SiIky
commit 9ca1ac62f9aa6e01afb3697cc4b966d085be9d3a
Author: SiIky <siiky_AT_users.noreply.github.com>
AuthorDate: Sat Feb 17 18:08:27 2018 +0000
Commit: SiIky <siiky_AT_users.noreply.github.com>
CommitDate: Sat Feb 17 18:08:27 2018 +0000
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.
diff --git a/slstatus.c b/slstatus.c
index 89a3268..19bc127 100644
--- a/slstatus.c
+++ b/slstatus.c
_AT_@ -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';
Received on Sat Feb 17 2018 - 21:00:43 CET
This archive was generated by hypermail 2.3.0
: Sat Feb 17 2018 - 21:12:23 CET