1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

Merge pull request #2294 from jprochazk/develop

fix eof for get_binary and get_string
This commit is contained in:
Niels Lohmann
2020-07-20 08:02:03 +02:00
committed by GitHub
3 changed files with 26 additions and 12 deletions

View File

@ -8143,15 +8143,16 @@ class binary_reader
string_t& result)
{
bool success = true;
std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
for (NumberType i = 0; i < len; i++)
{
get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string")))
{
success = false;
break;
}
return std::char_traits<char_type>::to_char_type(current);
});
result.push_back(std::char_traits<char_type>::to_char_type(current));
};
return success;
}
@ -8175,15 +8176,16 @@ class binary_reader
binary_t& result)
{
bool success = true;
std::generate_n(std::back_inserter(result), len, [this, &success, &format]()
for (NumberType i = 0; i < len; i++)
{
get();
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary")))
{
success = false;
break;
}
return static_cast<std::uint8_t>(current);
});
result.push_back(static_cast<std::uint8_t>(current));
}
return success;
}