Browse Source

Util: Fix Parser number error detection

master
Riyyi 3 years ago
parent
commit
5d844554f5
  1. 16
      src/util/json/parser.cpp

16
src/util/json/parser.cpp

@ -211,14 +211,16 @@ Value Parser::getNumber()
}
}
if (fractionPosition == exponentPosition - 1) {
reportError(token, "invalid exponent sign, expected number");
return nullptr;
}
if (fractionPosition != 0 || exponentPosition != 0) {
if (fractionPosition == exponentPosition - 1) {
reportError(token, "invalid exponent sign, expected number");
return nullptr;
}
if (fractionPosition == length - 1 || exponentPosition == length - 1) {
reportError(token, "invalid number");
return nullptr;
if (fractionPosition == length - 1 || exponentPosition == length - 1) {
reportError(token, "invalid number");
return nullptr;
}
}
return std::stod(token.symbol);

Loading…
Cancel
Save