⚗️ try 9 bytes

This commit is contained in:
Niels Lohmann 2021-01-21 22:01:09 +01:00
parent 29f7abf57d
commit 42218cac1b
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
2 changed files with 4 additions and 4 deletions

View File

@ -497,7 +497,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(8, '\0');
std::string sn(9, '\0');
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
}
@ -591,7 +591,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(8, '\0');
std::string sn(9, '\0');
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
}

View File

@ -16052,7 +16052,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(8, '\0');
std::string sn(9, '\0');
(std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn));
}
@ -16146,7 +16146,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(8, '\0');
std::string sn(9, '\0');
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
}