summary refs log tree commit diff
path: root/resolv/res_libc.c
diff options
context:
space:
mode:
Diffstat (limited to 'resolv/res_libc.c')
-rw-r--r--resolv/res_libc.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/resolv/res_libc.c b/resolv/res_libc.c
index 76abca8442..834773c32f 100644
--- a/resolv/res_libc.c
+++ b/resolv/res_libc.c
@@ -70,14 +70,8 @@ res_init(void) {
 		_res.retry = 4;
 	if (!(_res.options & RES_INIT))
 		_res.options = RES_DEFAULT;
-	else if (_res.nscount > 0) {
-		__res_nclose (&_res);	/* Close any VC sockets.  */
-
-		for (int ns = 0; ns < MAXNS; ns++) {
-			free (_res._u._ext.nsaddrs[ns]);
-			_res._u._ext.nsaddrs[ns] = NULL;
-		}
-	}
+	else if (_res.nscount > 0)
+		__res_iclose (&_res, true);	/* Close any VC sockets.  */
 
 	/*
 	 * This one used to initialize implicitly to zero, so unless the app
@@ -103,11 +97,7 @@ __res_maybe_init (res_state resp, int preinit)
 	if (resp->options & RES_INIT) {
 		if (__res_initstamp != resp->_u._ext.initstamp) {
 			if (resp->nscount > 0) {
-				__res_nclose (resp);
-				for (int ns = 0; ns < MAXNS; ns++) {
-					free (resp->_u._ext.nsaddrs[ns]);
-					resp->_u._ext.nsaddrs[ns] = NULL;
-				}
+				__res_iclose (resp, true);
 				return __res_vinit (resp, 1);
 			}
 		}