Private
Public Access
2
0

iio.c: Fix leaking filedescriptor on read error

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-12-21 15:37:37 +00:00
parent 8862ebd9f2
commit 15e400eaf2

View File

@@ -111,6 +111,7 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
fd = open(buf, O_RDONLY); fd = open(buf, O_RDONLY);
if (fd != -1) { if (fd != -1) {
if (read(fd, readbuf, 2 * sizeof(char)) != 2) { if (read(fd, readbuf, 2 * sizeof(char)) != 2) {
close(fd);
break; break;
} }
chan_num = ((int) strtol(readbuf, NULL, 10)); chan_num = ((int) strtol(readbuf, NULL, 10));