fix out of bounds error detected in msvc

This commit is contained in:
Thomas Fussell 2016-07-14 07:20:31 +08:00
parent 053508e8b7
commit 8e17339ef0

View File

@ -647,17 +647,17 @@ number_format_token number_format_parser::parse_next_token()
switch (current_char) switch (current_char)
{ {
case '[': case '[':
do
{
token.string.push_back(format_string_[position_++]);
}
while (format_string_[position_] != ']' && position_ < format_string_.size());
if (position_ == format_string_.size()) if (position_ == format_string_.size())
{ {
throw std::runtime_error("missing ]"); throw std::runtime_error("missing ]");
} }
do
{
token.string.push_back(format_string_[position_++]);
}
while (position_ < format_string_.size() && format_string_[position_] != ']');
if (token.string.empty()) if (token.string.empty())
{ {
throw std::runtime_error("empty []"); throw std::runtime_error("empty []");