src/led.c: make sure we don't try to close a NULL dir
@@ -113,12 +113,16 @@ mraa_led_init_internal(const char* led)
dev->count = cnt;
if (dev->led_name == NULL) {
syslog(LOG_CRIT, "led: init: unknown device specified");
+ if (dir != NULL) {
closedir(dir);
+ }
free(dev);
return NULL;
}
+ if (dir != NULL) {
closedir(dir);
+ }
return dev;
}
