1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 06:26:44 +02:00

Fix a bunch of Wformat-truncation warnings due to snprintf() misuse

This commit is contained in:
jfreegman
2020-10-24 14:44:41 -04:00
parent 26b5fe8f9d
commit 4c302da503
5 changed files with 16 additions and 15 deletions

View File

@ -491,10 +491,11 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, uint32_t num, bool sort)
update_friend_last_online(i, t);
char tempname[TOX_MAX_NAME_LENGTH] = {0};
get_nick_truncate(m, tempname, num);
snprintf(Friends.list[i].name, sizeof(Friends.list[i].name), "%s", tempname);
Friends.list[i].namelength = strlen(Friends.list[i].name);
char tempname[TOX_MAX_NAME_LENGTH + 1];
int name_len = get_nick_truncate(m, tempname, num);
memcpy(Friends.list[i].name, tempname, name_len);
Friends.list[i].name[name_len] = 0;
Friends.list[i].namelength = name_len;
if (i == Friends.max_idx) {
++Friends.max_idx;