Fix parse_float accepting invalid input

This commit is contained in:
Otto Winter 2019-05-24 19:32:59 +02:00
parent 422754ed63
commit 16c2929bb4
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E

View file

@ -257,7 +257,7 @@ std::string to_string(long double val) {
optional<float> parse_float(const std::string &str) {
char *end;
float value = ::strtof(str.c_str(), &end);
if (end == nullptr)
if (end == nullptr || end != str.end().base())
return {};
return value;
}