summaryrefslogtreecommitdiff
path: root/core/Messenger.c
diff options
context:
space:
mode:
authorLuke Champine <luke.champine@gmail.com>2013-08-05 11:22:47 -0400
committerLuke Champine <luke.champine@gmail.com>2013-08-05 11:22:47 -0400
commitd1f84efdd776aab2f2278755b3014835e58ed912 (patch)
tree8a7f0e913cb38d5c5ac5b9ec9dce4b27bd973642 /core/Messenger.c
parent519e22677a2aa450f26822e21b9b28b993480b5b (diff)
temporary fix to prevent m_addfriend from segfaulting
Diffstat (limited to 'core/Messenger.c')
-rw-r--r--core/Messenger.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index dee6eefc..57d485bb 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -114,7 +114,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length)
114 return FAERR_ALREADYSENT; 114 return FAERR_ALREADYSENT;
115 115
116 uint32_t i; 116 uint32_t i;
117 for (i = 0; i <= numfriends; ++i) { /*TODO: dynamic memory allocation, this will segfault if there are more than MAX_NUM_FRIENDS*/ 117 for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
118 if(friendlist[i].status == NOFRIEND) { 118 if(friendlist[i].status == NOFRIEND) {
119 DHT_addfriend(client_id); 119 DHT_addfriend(client_id);
120 friendlist[i].status = FRIEND_ADDED; 120 friendlist[i].status = FRIEND_ADDED;
@@ -138,7 +138,7 @@ int m_addfriend_norequest(uint8_t * client_id)
138 if (getfriend_id(client_id) != -1) 138 if (getfriend_id(client_id) != -1)
139 return -1; 139 return -1;
140 uint32_t i; 140 uint32_t i;
141 for (i = 0; i <= numfriends; ++i) {/*TODO: dynamic memory allocation, this will segfault if there are more than MAX_NUM_FRIENDS*/ 141 for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
142 if(friendlist[i].status == NOFRIEND) { 142 if(friendlist[i].status == NOFRIEND) {
143 DHT_addfriend(client_id); 143 DHT_addfriend(client_id);
144 friendlist[i].status = FRIEND_REQUESTED; 144 friendlist[i].status = FRIEND_REQUESTED;