Skip to content

Commit

Permalink
Fix stoi exception in yeti fwupdate
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <[email protected]>
  • Loading branch information
corneliusclaussen committed Jul 5, 2024
1 parent 7183fa4 commit 59269a7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions modules/YetiDriver/yeti_comms/firmware_version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,30 @@ class YetiFirmwareVersion {

// parse into major, minor and revision
if (tokens.size() >= 1) {
major = std::stoi(tokens[0]);
try {
major = std::stoi(tokens[0]);
} catch (...) {
// Set to 0 if we cannot parse it
major = 0;
}
}

if (tokens.size() >= 2) {
minor = std::stoi(tokens[1]);
try {
minor = std::stoi(tokens[1]);
} catch (...) {
// Set to 0 if we cannot parse it
minor = 0;
}
}

if (tokens.size() >= 3) {
revision = std::stoi(tokens[2]);
try {
revision = std::stoi(tokens[2]);
} catch (...) {
// Set to 0 if we cannot parse it
revision = 0;
}
}
}

Expand Down

0 comments on commit 59269a7

Please sign in to comment.