From 478d799ee35ae285eda22a11d4545d1ece39e3bb Mon Sep 17 00:00:00 2001 From: Jman012 Date: Tue, 19 Nov 2013 11:44:26 -0800 Subject: Added null check to each chat before incrementing. --- toxcore/Messenger.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'toxcore/Messenger.c') 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) uint32_t i; for (i = 0; i < m->numchats; i++) { - ret++; + if (m->chats[i]) { + ret++; + } } return ret; @@ -2212,8 +2214,10 @@ uint32_t copy_chatlist(Messenger *m, int *out_list, uint32_t list_size) break; /* Abandon ship */ } - out_list[i] = i; - ret++; + if (m->chats[i]) { + out_list[i] = i; + ret++; + } } return ret; -- cgit v1.2.3