Permalink
Browse files

Fixed segfault.

  • Loading branch information...
irungentoo committed Oct 20, 2016
1 parent 691dac3 commit ce60b9cf52dd20aedbe2f07ed29c96663f94c313
Showing with 14 additions and 1 deletion.
  1. +4 −0 auto_tests/dht_test.c
  2. +10 −1 toxcore/DHT.c
View
@@ -296,6 +296,10 @@ START_TEST(test_DHT_test)
c_sleep(500);
}
for (i = 0; i < NUM_DHT_FRIENDS; ++i) {
ck_assert_msg(DHT_delfriend(dhts[pairs[i].tox2], dhts[pairs[i].tox1]->self_public_key, 1) == 0, "Failed to delete friend");
}
for (i = 0; i < NUM_DHT; ++i) {
void *n = dhts[i]->net;
kill_DHT(dhts[i]);
View
@@ -813,11 +813,20 @@ static int dealloc_buckets(DHT_Bucket *bucket)
/* pk doesn't matter, want any nodes from both lower buckets. */
uint8_t pk[crypto_box_PUBLICKEYBYTES] = {0};
int ret = recursive_DHT_bucket_get_nodes(bucket, bucket->client_list, DHT_BUCKET_NODES, pk, 1, 1);
Client_data nodes[DHT_BUCKET_NODES];
int ret = recursive_DHT_bucket_get_nodes(bucket, nodes, DHT_BUCKET_NODES, pk, 1, 1);
recursive_free_buckets(bucket);
bucket->empty = 0;
if (ret >= 1) {
bucket->client_list = calloc(DHT_BUCKET_NODES, sizeof(Client_data));
if (bucket->client_list)
memcpy(bucket->client_list, nodes, sizeof(nodes));
}
if (ret >= 0) {
return 0;
} else {

0 comments on commit ce60b9c

Please sign in to comment.