gpio.c: Add fix for closing of uninitialzed fds
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
committed by
Mihai Tudor Panu
parent
d60bab2082
commit
89473e5ba4
@@ -68,7 +68,10 @@ mraa_gpio_close_event_handles_sysfs(int fds[], int num_fds)
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_fds; ++i) {
|
||||
close(fds[i]);
|
||||
// Check required to avoid closing stdin and of an uninitialized fd
|
||||
if(fds[i] != 0) {
|
||||
close(fds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
free(fds);
|
||||
@@ -603,7 +606,7 @@ mraa_gpio_interrupt_handler(void* arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int *fps = malloc(dev->num_pins * sizeof(int));
|
||||
int *fps = calloc(dev->num_pins, sizeof(int));
|
||||
if (!fps) {
|
||||
syslog(LOG_ERR, "mraa_gpio_interrupt_handler_multiple() malloc error");
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user