From 546d9415e1806565b6c8f413c8873726c6aa049f Mon Sep 17 00:00:00 2001 From: Justin Brewer Date: Tue, 17 Apr 2018 13:47:51 -0500 Subject: Fix a segfault on *BSD freeaddrinfo is not required by POSIX to be NULL-safe. OpenBSD will SIGSEGV. NetBSD will assert. FreeBSD up to 11.1 will SIGSEGV, while in future versions, it will be a silent NOP [1]. Commit d4b715f0aa97 ("Fix potential race in 'invalid timeout' tests") added a code path to _redisContextConnectTcp which calls freeaddrinfo(NULL), triggering the segfault. Put a NULL check around the call to freeaddrinfo. [1] - https://github.com/freebsd/freebsd/commit/e9167239034a1e475c3238f8d133ebf703424ee0 Signed-off-by: Justin Brewer --- net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net.c b/net.c index 4551f3e..7ce9ef4 100644 --- a/net.c +++ b/net.c @@ -412,7 +412,10 @@ addrretry: error: rv = REDIS_ERR; end: - freeaddrinfo(servinfo); + if(servinfo) { + freeaddrinfo(servinfo); + } + return rv; // Need to return REDIS_OK if alright } -- cgit v1.2.3