From: Brendan Le Foll Date: Mon, 21 Dec 2015 15:12:55 +0000 (+0000) Subject: iio.c: Fix closedir not always been called leaving to leaked handles X-Git-Tag: v0.9.0~12 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fmraa.git;a=commitdiff_plain;h=ee69045ea8f1fe535b2f9c95bac4296882c95e36 iio.c: Fix closedir not always been called leaving to leaked handles Signed-off-by: Brendan Le Foll --- 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) {