diff options
-rw-r--r-- | toxcore/Messenger.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 3757faf3..eb40cf10 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -351,12 +351,11 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le | |||
351 | * return 0 if success. | 351 | * return 0 if success. |
352 | * return -1 if failure. | 352 | * return -1 if failure. |
353 | */ | 353 | */ |
354 | static int setfriendname(Messenger *m, int friendnumber, uint8_t *name) | 354 | static int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint8_t len) |
355 | { | 355 | { |
356 | if (friend_not_valid(m, friendnumber)) | 356 | if (friend_not_valid(m, friendnumber)) |
357 | return -1; | 357 | return -1; |
358 | 358 | ||
359 | uint16_t len = strlen(name) + 1; | ||
360 | m->friendlist[friendnumber].name_length = len; | 359 | m->friendlist[friendnumber].name_length = len; |
361 | memcpy(m->friendlist[friendnumber].name, name, len); | 360 | memcpy(m->friendlist[friendnumber].name, name, len); |
362 | return 0; | 361 | return 0; |
@@ -1029,7 +1028,7 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length) | |||
1029 | for (i = 0; i < num; ++i) { | 1028 | for (i = 0; i < num; ++i) { |
1030 | if (temp[i].status >= 3) { | 1029 | if (temp[i].status >= 3) { |
1031 | int fnum = m_addfriend_norequest(m, temp[i].client_id); | 1030 | int fnum = m_addfriend_norequest(m, temp[i].client_id); |
1032 | setfriendname(m, fnum, temp[i].name); | 1031 | setfriendname(m, fnum, temp[i].name, temp[i].name_length); |
1033 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ | 1032 | /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ |
1034 | } else if (temp[i].status != 0) { | 1033 | } else if (temp[i].status != 0) { |
1035 | /* TODO: This is not a good way to do this. */ | 1034 | /* TODO: This is not a good way to do this. */ |