From 760329d91f844b9f0ad63e866d8b9a4395fe52c1 Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Sun, 15 Jan 2017 14:25:29 +0200 Subject: Fix a null-pointer dereference in read_device --- brightnessctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'brightnessctl.c') 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++; -- cgit v1.2.3