mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
top.cc: Dont crash on null, and fix for https://github.com/brndnmtthws/conky/issues/220
This commit is contained in:
parent
e29ebfa29f
commit
25eac4c0e5
@ -535,13 +535,19 @@ static void print_top_time(struct text_object *obj, char *p, int p_max_size) {
|
||||
|
||||
static void print_top_user(struct text_object *obj, char *p, int p_max_size) {
|
||||
auto *td = static_cast<struct top_data *>(obj->data.opaque);
|
||||
struct passwd *pw;
|
||||
|
||||
if ((td == nullptr) || (td->list == nullptr) ||
|
||||
(td->list[td->num] == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(p, p_max_size, "%.8s", getpwuid(td->list[td->num]->uid)->pw_name);
|
||||
pw = getpwuid(td->list[td->num]->uid);
|
||||
if (pw != nullptr) {
|
||||
snprintf(p, p_max_size, "%.8s", pw->pw_name);
|
||||
} else {
|
||||
NORM_ERR("The uid doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
#define PRINT_TOP_GENERATOR(name, width, fmt, field) \
|
||||
|
Loading…
Reference in New Issue
Block a user