From: Alex Rousskov Date: Sat, 11 May 2013 00:16:48 +0000 (-0600) Subject: Allocate ClientInfo::hash.key using malloc() instead of new char[] X-Git-Tag: SQUID_3_4_0_1~159 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fdb29403e215e16a1f303421d01b645cfd96b05b;p=thirdparty%2Fsquid.git 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. --- 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); }