>From d45aa7ebdbc243e9d5e550ed992f625e5d022b50 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 17 May 2014 19:13:27 +0200 Subject: [PATCH 5/5] resolv: Do not try to free addrinfo in case of error We should call freeaddrinfo only in situation if getaddrinfo succeeds. It is not specified in RFC2553 the behaviour of calling freeaddrinfo with the NULL argument. It is more portable to do not rely on undocumented behaviour of glibc. http://www.ietf.org/rfc/rfc2553.txt [Page 28] --- src/resolv/async_resolv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c index f0361ce8cf2679c22f7695ef1b64236e0d9d9216..38fa84d9f14a3d2f850feefa2c3076ae2618e659 100644 --- a/src/resolv/async_resolv.c +++ b/src/resolv/async_resolv.c @@ -1151,7 +1151,6 @@ resolv_is_address(const char *name) hints.ai_flags = AI_NUMERICHOST; /* No network lookups */ ret = getaddrinfo(name, NULL, &hints, &res); - freeaddrinfo(res); if (ret != 0) { if (ret == -2) { DEBUG(SSSDBG_TRACE_ALL, @@ -1160,6 +1159,8 @@ resolv_is_address(const char *name) DEBUG(SSSDBG_OP_FAILURE, "getaddrinfo failed [%d]: %s\n", ret, gai_strerror(ret)); } + } else { /* ret == 0 */ + freeaddrinfo(res); } return ret == 0; -- 1.9.0