From 3ad953c6c3ccbe2e68ec4a23765c99997b0c5145 Mon Sep 17 00:00:00 2001 From: "zugz (tox)" Date: Sun, 19 Apr 2020 00:00:00 +0000 Subject: fix saving of combination of loaded and connected TCP relays --- toxcore/Messenger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c96a330f..945d6556 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -3140,13 +3140,14 @@ static uint8_t *save_tcp_relays(const Messenger *m, uint8_t *data) Node_format relays[NUM_SAVED_TCP_RELAYS]; uint8_t *temp_data = data; data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY); - uint32_t num = copy_connected_tcp_relays(m->net_crypto, relays, NUM_SAVED_TCP_RELAYS); if (m->num_loaded_relays > 0) { memcpy(relays, m->loaded_relays, sizeof(Node_format) * m->num_loaded_relays); - num = min_u32(num + m->num_loaded_relays, NUM_SAVED_TCP_RELAYS); } + uint32_t num = m->num_loaded_relays; + num += copy_connected_tcp_relays(m->net_crypto, relays + num, NUM_SAVED_TCP_RELAYS - num); + int l = pack_nodes(data, NUM_SAVED_TCP_RELAYS * packed_node_size(net_family_tcp_ipv6), relays, num); if (l > 0) { -- cgit v1.2.3