diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/DHT.c | 6 | ||||
-rw-r--r-- | core/Lossless_UDP.c | 6 |
2 files changed, 12 insertions, 0 deletions
@@ -704,6 +704,12 @@ int DHT_delfriend(uint8_t *client_id) | |||
704 | CLIENT_ID_SIZE ); | 704 | CLIENT_ID_SIZE ); |
705 | } | 705 | } |
706 | 706 | ||
707 | if (num_friends == 0) { | ||
708 | free(friends_list); | ||
709 | friends_list = NULL; | ||
710 | return 0; | ||
711 | } | ||
712 | |||
707 | temp = realloc(friends_list, sizeof(Friend) * (num_friends)); | 713 | temp = realloc(friends_list, sizeof(Friend) * (num_friends)); |
708 | 714 | ||
709 | if (temp == NULL) | 715 | if (temp == NULL) |
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index fa5f9144..2210f7d3 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -319,6 +319,12 @@ static void free_connections(void) | |||
319 | if (connections_length == i) | 319 | if (connections_length == i) |
320 | return; | 320 | return; |
321 | 321 | ||
322 | if (i == 0) { | ||
323 | free(connections); | ||
324 | connections = NULL; | ||
325 | return; | ||
326 | } | ||
327 | |||
322 | Connection *temp; | 328 | Connection *temp; |
323 | temp = realloc(connections, sizeof(Connection) * i); | 329 | temp = realloc(connections, sizeof(Connection) * i); |
324 | 330 | ||