From fdb29403e215e16a1f303421d01b645cfd96b05b Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Fri, 10 May 2013 18:16:48 -0600 Subject: [PATCH] Allocate ClientInfo::hash.key using malloc() instead of new char[] because it is destroyed using free() instead of delete[]. Added ClientInfo construction/destruction debugging to find leaking objects. --- src/client_db.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client_db.cc b/src/client_db.cc index ca09ac233a..01aaf2edd2 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -79,8 +79,9 @@ static ClientInfo * clientdbAdd(const Ip::Address &addr) { ClientInfo *c; - char *buf = new char[MAX_IPSTRLEN]; + char *buf = static_cast(xmalloc(MAX_IPSTRLEN)); // becomes hash.key c = (ClientInfo *)memAllocate(MEM_CLIENT_INFO); + debugs(77, 9, "ClientInfo constructed, this=" << c); c->hash.key = addr.NtoA(buf,MAX_IPSTRLEN); c->addr = addr; #if USE_DELAY_POOLS @@ -354,6 +355,7 @@ clientdbFreeItem(void *data) } #endif + debugs(77, 9, "ClientInfo destructed, this=" << c); memFree(c, MEM_CLIENT_INFO); } -- 2.47.3