From 3674d3aa7c426c5ebfb7227dc7ba2553f300d96e Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sat, 18 May 2013 21:46:58 -0600 Subject: [PATCH] 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. --- 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 c8456cebd8..e034b1323b 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -72,8 +72,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 @@ -355,6 +356,7 @@ clientdbFreeItem(void *data) } #endif + debugs(77, 9, "ClientInfo destructed, this=" << c); memFree(c, MEM_CLIENT_INFO); } -- 2.39.2