Commit 7074a07e authored by DylanVanAssche's avatar DylanVanAssche

[iioadaptor] Improve strtol error handling. Contributes to MER#2076

parent b49a908c
......@@ -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: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment