summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Messenger.c6
-rw-r--r--core/net_crypto.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index 2b5c8241..8a5d9ed4 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -37,6 +37,8 @@ static int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_i
37 return -1 if realloc fails */ 37 return -1 if realloc fails */
38int realloc_friendlist(Messenger *m, uint32_t num) 38int realloc_friendlist(Messenger *m, uint32_t num)
39{ 39{
40 if (num * sizeof(Friend) == 0) return -1;
41
40 Friend *newfriendlist = realloc(m->friendlist, num * sizeof(Friend)); 42 Friend *newfriendlist = realloc(m->friendlist, num * sizeof(Friend));
41 43
42 if (newfriendlist == NULL && num != 0) 44 if (newfriendlist == NULL && num != 0)
@@ -597,7 +599,6 @@ int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint
597 599
598/*Interval in seconds between LAN discovery packet sending*/ 600/*Interval in seconds between LAN discovery packet sending*/
599#define LAN_DISCOVERY_INTERVAL 60 601#define LAN_DISCOVERY_INTERVAL 60
600
601#define PORT 33445 602#define PORT 33445
602 603
603/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/ 604/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/
@@ -951,6 +952,7 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length)
951 } 952 }
952 } 953 }
953 954
955 free(temp);
954 data += size; 956 data += size;
955 length -= size; 957 length -= size;
956 958
@@ -968,7 +970,5 @@ int Messenger_load(Messenger *m, uint8_t *data, uint32_t length)
968 970
969 setname(m, data, small_size); 971 setname(m, data, small_size);
970 972
971 free(temp);
972 return 0; 973 return 0;
973} 974}
974
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 7fdd035f..6ced942b 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -406,6 +406,8 @@ 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;
410
409 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection)); 411 Crypto_Connection *newcrypto_connections = realloc(crypto_connections, num * sizeof(Crypto_Connection));
410 412
411 if (newcrypto_connections == NULL && num != 0) 413 if (newcrypto_connections == NULL && num != 0)