Skip to content

Commit

Permalink
Fix strtoul error condition (#1995)
Browse files Browse the repository at this point in the history
endptr is set to '\0' when successful
  • Loading branch information
mcspr authored Nov 18, 2019
1 parent ab186e0 commit c96f2e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/espurna/utils.ino
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ namespace Heartbeat {
// invalidate the whole string when invalid chars are detected
char *value_endptr = nullptr;
const auto value = strtoul(cfg.c_str(), &value_endptr, 10);
if (value_endptr) {
if (value_endptr == cfg.c_str() || value_endptr[0] != '\0') {
return defaultValue();
}

Expand Down

0 comments on commit c96f2e4

Please sign in to comment.