iio/iio.c: Add fix for division by 0 bug
@@ -176,6 +176,13 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
// have grabbed all the correct info
for (i = 0; i < dev->chan_num; i++) {
chan = &dev->channels[i];
+
+ if(chan->bytes <= 0)
+ {
+ syslog(LOG_ERR, "iio: Channel %d with channel bytes value <= 0");
+ return MRAA_IO_SETUP_FAILURE;
+ }
+
if (curr_bytes % chan->bytes == 0) {
chan->location = curr_bytes;
} else {
