diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/assoc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/toxcore/assoc.c b/toxcore/assoc.c index 4d837aa3..417b6139 100644 --- a/toxcore/assoc.c +++ b/toxcore/assoc.c | |||
@@ -831,8 +831,20 @@ Assoc *new_Assoc(size_t bits, size_t entries, const uint8_t *public_id) | |||
831 | /* allocation: preferably few blobs */ | 831 | /* allocation: preferably few blobs */ |
832 | size_t bckt, cix; | 832 | size_t bckt, cix; |
833 | Client_entry *clients = malloc(sizeof(*clients) * assoc->candidates_bucket_count * assoc->candidates_bucket_size); | 833 | Client_entry *clients = malloc(sizeof(*clients) * assoc->candidates_bucket_count * assoc->candidates_bucket_size); |
834 | |||
835 | if (!clients) { | ||
836 | free(assoc); | ||
837 | return NULL; | ||
838 | } | ||
839 | |||
834 | candidates_bucket *lists = malloc(sizeof(*lists) * assoc->candidates_bucket_count); | 840 | candidates_bucket *lists = malloc(sizeof(*lists) * assoc->candidates_bucket_count); |
835 | 841 | ||
842 | if (!lists) { | ||
843 | free(assoc); | ||
844 | free(clients); | ||
845 | return NULL; | ||
846 | } | ||
847 | |||
836 | for (bckt = 0; bckt < assoc->candidates_bucket_count; bckt++) { | 848 | for (bckt = 0; bckt < assoc->candidates_bucket_count; bckt++) { |
837 | candidates_bucket *list = &lists[bckt]; | 849 | candidates_bucket *list = &lists[bckt]; |
838 | 850 | ||