Skip to content

Commit

Permalink
🚨 fix format-truncation warning #2572
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jan 15, 2021
1 parent 92fa1d9 commit 29f7abf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/nlohmann/detail/output/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(3, '\0');
std::string sn(8, '\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));
}
Expand Down Expand Up @@ -591,7 +591,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(3, '\0');
std::string sn(8, '\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));
}
Expand Down
4 changes: 2 additions & 2 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16052,7 +16052,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(3, '\0');
std::string sn(8, '\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));
}
Expand Down Expand Up @@ -16146,7 +16146,7 @@ class serializer
{
case error_handler_t::strict:
{
std::string sn(3, '\0');
std::string sn(8, '\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));
}
Expand Down

0 comments on commit 29f7abf

Please sign in to comment.