[fix] call memset() before using strncpy()

This commit is contained in:
dijunkun
2024-08-13 17:07:19 +08:00
parent d1f3d11318
commit 2cde54cf30
3 changed files with 5 additions and 1 deletions

View File

@@ -237,6 +237,7 @@ void Render::NetStatusReport(int client_id, TraversalMode mode,
Render *render = (Render *)user_data;
if (client_id != 0 && 0 == strcmp(render->client_id_, "")) {
std::string client_id_s = std::to_string(client_id);
memset(&render->client_id_, 0, sizeof(render->client_id_));
strncpy(render->client_id_, client_id_s.c_str(),
sizeof(render->client_id_));
LOG_INFO("Use client id [{}] and save id into cache file", client_id_s);