summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2020-04-19 00:00:00 +0000
committerzugz (tox) <mbays+tox@sdf.org>2020-04-19 00:00:01 +0000
commit3ad953c6c3ccbe2e68ec4a23765c99997b0c5145 (patch)
tree04786b22ddb02c67b6dbc3e6c9d7e344537b13dc
parentcdafc6ff5ee13595ecf5a4e1fe0cb28e255c37df (diff)
fix saving of combination of loaded and connected TCP relays
-rw-r--r--toxcore/Messenger.c5
1 files 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)
3140 Node_format relays[NUM_SAVED_TCP_RELAYS]; 3140 Node_format relays[NUM_SAVED_TCP_RELAYS];
3141 uint8_t *temp_data = data; 3141 uint8_t *temp_data = data;
3142 data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY); 3142 data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY);
3143 uint32_t num = copy_connected_tcp_relays(m->net_crypto, relays, NUM_SAVED_TCP_RELAYS);
3144 3143
3145 if (m->num_loaded_relays > 0) { 3144 if (m->num_loaded_relays > 0) {
3146 memcpy(relays, m->loaded_relays, sizeof(Node_format) * m->num_loaded_relays); 3145 memcpy(relays, m->loaded_relays, sizeof(Node_format) * m->num_loaded_relays);
3147 num = min_u32(num + m->num_loaded_relays, NUM_SAVED_TCP_RELAYS);
3148 } 3146 }
3149 3147
3148 uint32_t num = m->num_loaded_relays;
3149 num += copy_connected_tcp_relays(m->net_crypto, relays + num, NUM_SAVED_TCP_RELAYS - num);
3150
3150 int l = pack_nodes(data, NUM_SAVED_TCP_RELAYS * packed_node_size(net_family_tcp_ipv6), relays, num); 3151 int l = pack_nodes(data, NUM_SAVED_TCP_RELAYS * packed_node_size(net_family_tcp_ipv6), relays, num);
3151 3152
3152 if (l > 0) { 3153 if (l > 0) {