From 820bd715d7d3196d769a191d04fa9dffea0b2204 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 12 Aug 2012 03:12:23 -0600 Subject: [PATCH] Bug 3605: memory leak in peer selection --- src/peer_select.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/peer_select.cc b/src/peer_select.cc index 6ef1adffe6..13805f3fc9 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -269,6 +269,18 @@ peerSelectDnsPaths(ps_state *psstate) return; } + // Bug 3605: clear any extra listed FwdServer destinations, when the options exceeds max_foward_tries. + // due to the allocation method of fs, we must deallocate each manually. + // TODO: use a std::list so we can get the size and abort adding whenever the selection loops reach Config.forward_max_tries + if (fs && psstate->paths->size() >= (unsigned int)Config.forward_max_tries) { + while(fs) { + FwdServer *next = fs->next; + cbdataReferenceDone(fs->_peer); + memFree(fs, MEM_FWD_SERVER); + fs = next; + } + } + // done with DNS lookups. pass back to caller PSC *callback = psstate->callback; psstate->callback = NULL; -- 2.47.2