From: Amos Jeffries Date: Sun, 12 Aug 2012 09:12:23 +0000 (-0600) Subject: Bug 3605: memory leak in peer selection X-Git-Tag: SQUID_3_2_1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=820bd715d7d3196d769a191d04fa9dffea0b2204;p=thirdparty%2Fsquid.git Bug 3605: memory leak in peer selection --- 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;