Skip to content

Commit

Permalink
Use snprintf instead of sprintf in example.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Dec 2, 2024
1 parent 4c034a5 commit 959a4bb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion asio/src/examples/cpp11/chat/chat_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class chat_message
void encode_header()
{
char header[header_length + 1] = "";
std::sprintf(header, "%4d", static_cast<int>(body_length_));
std::snprintf(header, header_length + 1,
"%4d", static_cast<int>(body_length_));
std::memcpy(data_, header, header_length);
}

Expand Down

0 comments on commit 959a4bb

Please sign in to comment.