From ee69045ea8f1fe535b2f9c95bac4296882c95e36 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Mon, 21 Dec 2015 15:12:55 +0000 Subject: [PATCH] iio.c: Fix closedir not always been called leaving to leaked handles Signed-off-by: Brendan Le Foll --- src/iio/iio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/iio/iio.c b/src/iio/iio.c index d8b0546..40ddcbb 100755 --- a/src/iio/iio.c +++ b/src/iio/iio.c @@ -98,8 +98,10 @@ mraa_iio_get_channel_data(mraa_iio_context dev) } dev->chan_num = chan_num; // no need proceed if no channel found - if (chan_num == 0) + if (chan_num == 0) { + closedir(dir); return MRAA_SUCCESS; + } mraa_iio_channel* chan; dev->channels = calloc(chan_num, sizeof(mraa_iio_channel)); seekdir(dir, 0); @@ -169,6 +171,7 @@ mraa_iio_get_channel_data(mraa_iio_context dev) } } } + closedir(dir); return MRAA_SUCCESS; } @@ -371,8 +374,10 @@ mraa_iio_get_event_data(mraa_iio_context dev) } dev->event_num = event_num; // no need proceed if no event found - if (event_num == 0) + if (event_num == 0) { + closedir(dir); return MRAA_SUCCESS; + } mraa_iio_event* event; dev->events = calloc(event_num, sizeof(mraa_iio_event)); if (dev->events == NULL) { -- 2.7.4