From 268bec4cd0d562394c2c27d10a26be1264bc8648 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 9 Mar 2022 23:18:31 +0800 Subject: ... --- src/common/StringToNumberConverter.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/StringToNumberConverter.cpp b/src/common/StringToNumberConverter.cpp index 259e39b0..d77f7886 100644 --- a/src/common/StringToNumberConverter.cpp +++ b/src/common/StringToNumberConverter.cpp @@ -143,10 +143,21 @@ StringToIntegerConverterImplResult StringToIntegerConverterImpl::Parse( while (current != end && IsSpace(*current)) { current++; } + + if (current != end) { + if (processed_characters_count) { + *processed_characters_count = 0; + } + if (throw_on_error) { + throw Exception(u"There is trailing junk."); + } else { + return {false, 0}; + } + } } - if (current != end) { - throw Exception(u"There is trailing junk."); + if (processed_characters_count) { + *processed_characters_count = current - str; } return {negate, result}; -- cgit v1.2.3