summaryrefslogtreecommitdiff
path: root/toxcore/TCP_client.c
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2018-09-29 10:49:52 +0200
committerzugz (tox) <mbays+tox@sdf.org>2018-10-07 20:13:51 +0200
commit5beb00c93d3adb5c23149535624d27c67bc146ea (patch)
tree270dcde41751d421fae86f8f466038c212ed559d /toxcore/TCP_client.c
parentb2b96b1aa19ef2eb2816303e606a3f23550538dc (diff)
Fix memleak in tcp server by wiping priority queues on deletion
Diffstat (limited to 'toxcore/TCP_client.c')
-rw-r--r--toxcore/TCP_client.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c
index d8922eaa..6eae8408 100644
--- a/toxcore/TCP_client.c
+++ b/toxcore/TCP_client.c
@@ -419,17 +419,6 @@ static bool client_add_priority(TCP_Client_Connection *con, const uint8_t *packe
419 return 1; 419 return 1;
420} 420}
421 421
422static void wipe_priority_list(TCP_Client_Connection *con)
423{
424 TCP_Priority_List *p = con->priority_queue_start;
425
426 while (p) {
427 TCP_Priority_List *pp = p;
428 p = p->next;
429 free(pp);
430 }
431}
432
433/* return 1 on success. 422/* return 1 on success.
434 * return 0 if could not send packet. 423 * return 0 if could not send packet.
435 * return -1 on failure (connection must be killed). 424 * return -1 on failure (connection must be killed).
@@ -1075,7 +1064,7 @@ void kill_TCP_connection(TCP_Client_Connection *tcp_connection)
1075 return; 1064 return;
1076 } 1065 }
1077 1066
1078 wipe_priority_list(tcp_connection); 1067 wipe_priority_list(tcp_connection->priority_queue_start);
1079 kill_sock(tcp_connection->sock); 1068 kill_sock(tcp_connection->sock);
1080 crypto_memzero(tcp_connection, sizeof(TCP_Client_Connection)); 1069 crypto_memzero(tcp_connection, sizeof(TCP_Client_Connection));
1081 free(tcp_connection); 1070 free(tcp_connection);