summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authorJman012 <jman012guy@gmail.com>2013-11-19 11:44:26 -0800
committerJman012 <jman012guy@gmail.com>2013-11-19 11:44:26 -0800
commit478d799ee35ae285eda22a11d4545d1ece39e3bb (patch)
tree6d1b0c02d1166425385da722f4035a41fa9ddd36 /toxcore/Messenger.c
parent21e514572cb2f93b141f60a2876e083c651f4f39 (diff)
Added null check to each chat before incrementing.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 14f01373..725a92e6 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -2184,7 +2184,9 @@ uint32_t count_chatlist(Messenger *m)
2184 uint32_t i; 2184 uint32_t i;
2185 2185
2186 for (i = 0; i < m->numchats; i++) { 2186 for (i = 0; i < m->numchats; i++) {
2187 ret++; 2187 if (m->chats[i]) {
2188 ret++;
2189 }
2188 } 2190 }
2189 2191
2190 return ret; 2192 return ret;
@@ -2212,8 +2214,10 @@ uint32_t copy_chatlist(Messenger *m, int *out_list, uint32_t list_size)
2212 break; /* Abandon ship */ 2214 break; /* Abandon ship */
2213 } 2215 }
2214 2216
2215 out_list[i] = i; 2217 if (m->chats[i]) {
2216 ret++; 2218 out_list[i] = i;
2219 ret++;
2220 }
2217 } 2221 }
2218 2222
2219 return ret; 2223 return ret;