Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zgfzgf committed Jun 16, 2020
1 parent 9e619fa commit f65cd9f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions toxcore/DHT.c
Expand Up @@ -758,14 +758,15 @@ bool add_to_list(Node_format *nodes_list, uint32_t length, const uint8_t *pk, IP
memcpy(pk_new, pk, CRYPTO_PUBLIC_KEY_SIZE);
IP_Port ip_port_new = ip_port;

uint8_t pk_bak[CRYPTO_PUBLIC_KEY_SIZE];
IP_Port ip_port_bak;
for (uint32_t i = 0; i < length; ++i) {
if (id_closest(cmp_pk, nodes_list[i].public_key, pk_new) == 2) {
uint8_t pk_bak[CRYPTO_PUBLIC_KEY_SIZE];
if (id_closest(cmp_pk, nodes_list[i].public_key, pk_new) == 2) {
memcpy(pk_bak, nodes_list[i].public_key, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(nodes_list[i].public_key, pk_new, CRYPTO_PUBLIC_KEY_SIZE);
memcpy(pk_new, pk_bak, CRYPTO_PUBLIC_KEY_SIZE);

const IP_Port ip_port_bak = nodes_list[i].ip_port;
ip_port_bak = nodes_list[i].ip_port;
nodes_list[i].ip_port = ip_port_new;
ip_port_new = ip_port_bak;

Expand Down

0 comments on commit f65cd9f

Please sign in to comment.