From 5a1897162b16ec8aeccef2428e663748ab7852f5 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Mon, 9 Sep 2013 07:11:30 -0400 Subject: [PATCH] a better way --- toxcore/Messenger.c | 5 ++--- 1 file 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 * return 0 if success. * return -1 if failure. */ -static int setfriendname(Messenger *m, int friendnumber, uint8_t *name) +static int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint8_t len) { if (friend_not_valid(m, friendnumber)) return -1; - uint16_t len = strlen(name) + 1; m->friendlist[friendnumber].name_length = len; memcpy(m->friendlist[friendnumber].name, name, len); return 0; @@ -1029,7 +1028,7 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length) for (i = 0; i < num; ++i) { if (temp[i].status >= 3) { int fnum = m_addfriend_norequest(m, temp[i].client_id); - setfriendname(m, fnum, temp[i].name); + setfriendname(m, fnum, temp[i].name, temp[i].name_length); /* set_friend_statusmessage(fnum, temp[i].statusmessage, temp[i].statusmessage_length); */ } else if (temp[i].status != 0) { /* TODO: This is not a good way to do this. */