diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2017-01-15 14:25:29 +0200 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2017-01-15 14:25:29 +0200 |
commit | 760329d91f844b9f0ad63e866d8b9a4395fe52c1 (patch) | |
tree | 4b3577e1b0299befc153e3fb27e67777c5358e7f | |
parent | 3554aca4181ede432725fef82c171f584b284e67 (diff) |
Fix a null-pointer dereference in read_device
-rw-r--r-- | brightnessctl.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/brightnessctl.c b/brightnessctl.c index cbfe410..c0ffd0a 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -320,7 +320,7 @@ int read_device(struct device *d, char *class, char *id) { d->id = strdup(id); dev_path = device_path(d); if (!(dirp = opendir(dev_path))) - goto fail; + goto dfail; while ((ent = readdir(dirp))) { if (!strcmp(ent->d_name, ".") && !strcmp(ent->d_name, "..")) continue; @@ -356,6 +356,7 @@ int read_device(struct device *d, char *class, char *id) { errno = 0; fail: closedir(dirp); +dfail: if (errno) { perror("Error reading device"); error++; |