From: Alex Rousskov Date: Sun, 19 May 2013 03:27:30 +0000 (-0600) Subject: Allocate ClientInfo::hash.key using malloc() instead of new char[] X-Git-Tag: SQUID_3_3_5~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=368176642fa627bebba24234dfd48699db1fbedd;p=thirdparty%2Fsquid.git Allocate ClientInfo::hash.key using malloc() instead of new char[] ... because it is destroyed using safe_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 cce0a12c04..0e0fb60854 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 @@ -362,6 +363,7 @@ clientdbFreeItem(void *data) } #endif + debugs(77, 9, "ClientInfo destructed, this=" << c); memFree(c, MEM_CLIENT_INFO); }