diff --git a/adaptors/iioadaptor/iioadaptor.cpp b/adaptors/iioadaptor/iioadaptor.cpp index 23b8593c..e2b25eff 100644 --- a/adaptors/iioadaptor/iioadaptor.cpp +++ b/adaptors/iioadaptor/iioadaptor.cpp @@ -434,10 +434,15 @@ void IioAdaptor::processSample(int fileId, int fd) sensordLogW() << "read():" << strerror(errno); return; } - result = strtol(buf, NULL, 10); - if (result == 0) + errno = 0; // reset errno before call + result = strtol(buf, NULL, 10); + + // If any conversion error occurs, abort + if (errno != 0) { + sensordLogW() << "strtol(): Unable to convert string to long"; return; + } switch(channel) { case 0: {