From c179d9a57b41f353b58555e70efa310581bced60 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Sun, 17 Jun 2018 10:01:44 -0400 Subject: [PATCH] start_listen_sockets: exit if no addresses Do not allocate a 0 byte buffer if no addresses are available: common.c:122:14: warning: Call to 'malloc' has an allocation size of 0 bytes *sockfd = malloc(num_addr * sizeof(*sockfd[0])); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common.c b/common.c index ca17354..378eb9a 100644 --- a/common.c +++ b/common.c @@ -116,6 +116,11 @@ int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list) for (addr = addr_list; addr; addr = addr->ai_next) num_addr++; + if (num_addr == 0) { + fprintf(stderr, "FATAL: No available addresses.\n"); + exit(1); + } + if (verbose) fprintf(stderr, "listening to %d addresses\n", num_addr);