Fix resource leak in resolver (bug 19257)

Message ID mvmio4zqq9x.fsf@hawking.suse.de
State New, archived
Headers

Commit Message

Andreas Schwab Nov. 18, 2015, 3:30 p.m. UTC
  The number of currently defined nameservers is stored in ->nscount,
whereas ->_u._ext.nscount is set by __libc_res_nsend only after local
initializations.

Andreas.

	* resolv/res_init.c (__res_iclose): Use statp->nscount instead of
	statp->_u._ext.nscount as loop count.
---
 resolv/res_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/resolv/res_init.c b/resolv/res_init.c
index c5dc801..a14e981 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -593,7 +593,7 @@  __res_iclose(res_state statp, bool free_addr) {
 		statp->_vcsock = -1;
 		statp->_flags &= ~(RES_F_VC | RES_F_CONN);
 	}
-	for (ns = 0; ns < statp->_u._ext.nscount; ns++)
+	for (ns = 0; ns < statp->nscount; ns++)
 		if (statp->_u._ext.nsaddrs[ns]) {
 			if (statp->_u._ext.nssocks[ns] != -1) {
 				close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);