mirror of
https://github.com/TokTok/c-toxcore
synced 2026-06-06 12:31:40 +00:00
Fix bug where we could run past the end of the friends list
This commit is contained in:
+2
-2
@@ -116,7 +116,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length)
|
||||
return FAERR_ALREADYSENT;
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
|
||||
for (i = 0; i < numfriends && i < MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
|
||||
if(friendlist[i].status == NOFRIEND) {
|
||||
DHT_addfriend(client_id);
|
||||
friendlist[i].status = FRIEND_ADDED;
|
||||
@@ -141,7 +141,7 @@ int m_addfriend_norequest(uint8_t * client_id)
|
||||
if (getfriend_id(client_id) != -1)
|
||||
return -1;
|
||||
uint32_t i;
|
||||
for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
|
||||
for (i = 0; i < numfriends && i < MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
|
||||
if(friendlist[i].status == NOFRIEND) {
|
||||
DHT_addfriend(client_id);
|
||||
friendlist[i].status = FRIEND_REQUESTED;
|
||||
|
||||
Reference in New Issue
Block a user