From 617718795472e3be31c5c11cc038b8634ede0b62 Mon Sep 17 00:00:00 2001 From: Nicolas Tsiftes Date: Thu, 1 Dec 2011 14:40:00 +0100 Subject: [PATCH] Check the return value of udp_new. --- examples/ipv6/rpl-udp/udp-client.c | 4 ++++ examples/ipv6/rpl-udp/udp-server.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/examples/ipv6/rpl-udp/udp-client.c b/examples/ipv6/rpl-udp/udp-client.c index 037408858..67e4de7e8 100644 --- a/examples/ipv6/rpl-udp/udp-client.c +++ b/examples/ipv6/rpl-udp/udp-client.c @@ -161,6 +161,10 @@ PROCESS_THREAD(udp_client_process, ev, data) /* new connection with remote host */ client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); + if(client_conn == NULL) { + PRINTF("No UDP connection available, exiting the process!\n"); + PROCESS_EXIT(); + } udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); diff --git a/examples/ipv6/rpl-udp/udp-server.c b/examples/ipv6/rpl-udp/udp-server.c index cbafb0da3..33f8cd761 100644 --- a/examples/ipv6/rpl-udp/udp-server.c +++ b/examples/ipv6/rpl-udp/udp-server.c @@ -152,6 +152,10 @@ PROCESS_THREAD(udp_server_process, ev, data) NETSTACK_MAC.off(1); server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL); + if(server_conn == NULL) { + PRINTF("No UDP connection available, exiting the process!\n"); + PROCESS_EXIT(); + } udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT)); PRINTF("Created a server connection with remote address ");