diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/Messenger.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 1809fc4c..f566a344 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -44,7 +44,13 @@ static int send_avatar_data_control(const Messenger *m, const uint32_t friendnum | |||
44 | // friend_not_valid determines if the friendnumber passed is valid in the Messenger object | 44 | // friend_not_valid determines if the friendnumber passed is valid in the Messenger object |
45 | static uint8_t friend_not_valid(const Messenger *m, int32_t friendnumber) | 45 | static uint8_t friend_not_valid(const Messenger *m, int32_t friendnumber) |
46 | { | 46 | { |
47 | return (unsigned int)friendnumber >= m->numfriends; | 47 | if ((unsigned int)friendnumber < m->numfriends) { |
48 | if (m->friendlist[friendnumber].status != 0) { | ||
49 | return 0; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | return 1; | ||
48 | } | 54 | } |
49 | 55 | ||
50 | static int add_online_friend(Messenger *m, int32_t friendnumber) | 56 | static int add_online_friend(Messenger *m, int32_t friendnumber) |
@@ -113,12 +119,8 @@ int get_real_pk(const Messenger *m, int32_t friendnumber, uint8_t *real_pk) | |||
113 | if (friend_not_valid(m, friendnumber)) | 119 | if (friend_not_valid(m, friendnumber)) |
114 | return -1; | 120 | return -1; |
115 | 121 | ||
116 | if (m->friendlist[friendnumber].status > 0) { | 122 | memcpy(real_pk, m->friendlist[friendnumber].real_pk, crypto_box_PUBLICKEYBYTES); |
117 | memcpy(real_pk, m->friendlist[friendnumber].real_pk, crypto_box_PUBLICKEYBYTES); | 123 | return 0; |
118 | return 0; | ||
119 | } | ||
120 | |||
121 | return -1; | ||
122 | } | 124 | } |
123 | 125 | ||
124 | /* return friend connection id on success. | 126 | /* return friend connection id on success. |
@@ -364,7 +366,7 @@ int m_friend_exists(const Messenger *m, int32_t friendnumber) | |||
364 | if (friend_not_valid(m, friendnumber)) | 366 | if (friend_not_valid(m, friendnumber)) |
365 | return 0; | 367 | return 0; |
366 | 368 | ||
367 | return m->friendlist[friendnumber].status > NOFRIEND; | 369 | return 1; |
368 | } | 370 | } |
369 | 371 | ||
370 | /* Send a text chat message to an online friend. | 372 | /* Send a text chat message to an online friend. |