From: Amos Jeffries Date: Sun, 12 Aug 2012 08:57:49 +0000 (-0600) Subject: Bug 3605: memory leak in peer selection X-Git-Tag: sourceformat-review-1~112 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2f4e9cc4299889bf7e23f47a8d36f512e2ea81e;p=thirdparty%2Fsquid.git Bug 3605: memory leak in peer selection --- diff --git a/src/peer_select.cc b/src/peer_select.cc index 763085c21b..373a14a4c3 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -259,6 +259,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;