Fixed segfault.

This commit is contained in:
irungentoo 2016-10-20 18:20:34 -04:00
parent 691dac3cb0
commit ce60b9cf52
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 14 additions and 1 deletions

View File

@ -296,6 +296,10 @@ loop_top:
c_sleep(500); 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) { for (i = 0; i < NUM_DHT; ++i) {
void *n = dhts[i]->net; void *n = dhts[i]->net;
kill_DHT(dhts[i]); kill_DHT(dhts[i]);

View File

@ -813,11 +813,20 @@ static int dealloc_buckets(DHT_Bucket *bucket)
/* pk doesn't matter, want any nodes from both lower buckets. */ /* pk doesn't matter, want any nodes from both lower buckets. */
uint8_t pk[crypto_box_PUBLICKEYBYTES] = {0}; 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); recursive_free_buckets(bucket);
bucket->empty = 0; 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) { if (ret >= 0) {
return 0; return 0;
} else { } else {