From 747c290269db58f68ce05e976af974f3904ac3d0 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 20 Aug 2013 15:53:15 -0400 Subject: Fixed DHT_test.c and added some checks. --- core/DHT.c | 2 ++ core/Lossless_UDP.c | 2 ++ core/Messenger.c | 2 +- core/net_crypto.c | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/DHT.c b/core/DHT.c index a139f2c5..c8994437 100644 --- a/core/DHT.c +++ b/core/DHT.c @@ -1145,6 +1145,8 @@ static void do_toping(DHT * dht) DHT * new_DHT(Net_Crypto *c) { + if (c == NULL) + return NULL; DHT * temp = calloc(1, sizeof(DHT)); if (temp == NULL) return NULL; diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 3e71ffbb..7ece28e1 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c @@ -719,6 +719,8 @@ static int handle_data(void * object, IP_Port source, uint8_t *packet, uint32_t Lossless_UDP * new_lossless_udp(Networking_Core * net) { + if(net == NULL) + return NULL; Lossless_UDP * temp = calloc(1, sizeof(Lossless_UDP)); if (temp == NULL) return NULL; diff --git a/core/Messenger.c b/core/Messenger.c index a6cbb3ac..dcf0235f 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -625,7 +625,7 @@ Messenger *initMessenger(void) { Messenger *m = calloc(1, sizeof(Messenger)); if ( ! m ) - return 0; + return NULL; IP ip; ip.i = 0; m->net = new_networking(ip, PORT); diff --git a/core/net_crypto.c b/core/net_crypto.c index e36a1666..6c915f49 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c @@ -699,6 +699,8 @@ static void receive_crypto(Net_Crypto *c) sets all the global connection variables to their default values. */ Net_Crypto * new_net_crypto(Networking_Core * net) { + if (net == NULL) + return NULL; Net_Crypto * temp = calloc(1, sizeof(Net_Crypto)); if (temp == NULL) return NULL; -- cgit v1.2.3