diff --git a/src/mraa.c b/src/mraa.c index 653ea1f..b556d04 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -12,6 +12,7 @@ #endif #include +#include #include #include #include @@ -341,9 +342,11 @@ static int mraa_count_iio_devices(const char* path, const struct stat* sb, int flag, struct FTW* ftwb) { // we are only interested in files with specific names - if (fnmatch(IIO_DEVICE_WILDCARD, basename(path), 0) == 0) { + char* tmp = strdup(path); + if (fnmatch(IIO_DEVICE_WILDCARD, basename(tmp), 0) == 0) { num_iio_devices++; } + free(tmp); return 0; }