From 5d844554f59733de44d6311347d44560b0e8a0c3 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Fri, 1 Jul 2022 11:49:20 +0200 Subject: [PATCH] Util: Fix Parser number error detection --- src/util/json/parser.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/util/json/parser.cpp b/src/util/json/parser.cpp index f1ec12f..48e8676 100644 --- a/src/util/json/parser.cpp +++ b/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);