summaryrefslogtreecommitdiff
path: root/core/net_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/net_crypto.c')
-rw-r--r--core/net_crypto.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 6ced942b..a9af3430 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -406,11 +406,15 @@ static int getcryptconnection_id(uint8_t *public_key)
406 return -1 if realloc fails */ 406 return -1 if realloc fails */
407int realloc_cryptoconnection(uint32_t num) 407int realloc_cryptoconnection(uint32_t num)
408{ 408{
409 if (num * sizeof(Crypto_Connection) == 0) return -1; 409 if (num == 0) {
410 free(crypto_connections);
411 crypto_connections = NULL;
412 return 0;
413 }
410 414
411 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection)); 415 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection));
412 416
413 if (newcrypto_connections == NULL && num != 0) 417 if (newcrypto_connections == NULL)
414 return -1; 418 return -1;
415 419
416 crypto_connections = newcrypto_connections; 420 crypto_connections = newcrypto_connections;