mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 07:28:10 +01:00
Fix parse_float accepting invalid input
This commit is contained in:
parent
422754ed63
commit
16c2929bb4
1 changed files with 1 additions and 1 deletions
|
@ -257,7 +257,7 @@ std::string to_string(long double val) {
|
||||||
optional<float> parse_float(const std::string &str) {
|
optional<float> parse_float(const std::string &str) {
|
||||||
char *end;
|
char *end;
|
||||||
float value = ::strtof(str.c_str(), &end);
|
float value = ::strtof(str.c_str(), &end);
|
||||||
if (end == nullptr)
|
if (end == nullptr || end != str.end().base())
|
||||||
return {};
|
return {};
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue