diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 659c837b..66faa4db 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1539,12 +1539,15 @@ void do_friends(Messenger *m) | |||
1539 | if (data_length >= MAX_NAME_LENGTH || data_length == 0) | 1539 | if (data_length >= MAX_NAME_LENGTH || data_length == 0) |
1540 | break; | 1540 | break; |
1541 | 1541 | ||
1542 | memcpy(m->friendlist[i].name, data, data_length); | 1542 | /* Make sure the NULL terminator is present. */ |
1543 | m->friendlist[i].name_length = data_length; | 1543 | data[data_length - 1] = 0; |
1544 | m->friendlist[i].name[data_length - 1] = 0; /* Make sure the NULL terminator is present. */ | ||
1545 | 1544 | ||
1545 | /* inform of namechange before we overwrite the old name */ | ||
1546 | if (m->friend_namechange) | 1546 | if (m->friend_namechange) |
1547 | m->friend_namechange(m, i, m->friendlist[i].name, data_length, m->friend_namechange_userdata); | 1547 | m->friend_namechange(m, i, data, data_length, m->friend_namechange_userdata); |
1548 | |||
1549 | memcpy(m->friendlist[i].name, data, data_length); | ||
1550 | m->friendlist[i].name_length = data_length; | ||
1548 | 1551 | ||
1549 | break; | 1552 | break; |
1550 | } | 1553 | } |