]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Allocate ClientInfo::hash.key using malloc() instead of new char[]
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 19 May 2013 03:27:30 +0000 (21:27 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 19 May 2013 03:27:30 +0000 (21:27 -0600)
... because it is destroyed using safe_free() instead of delete[].

Added ClientInfo construction/destruction debugging to find leaking objects.

src/client_db.cc

index cce0a12c042fe11b08fcbdb469c35027e9fa0d9b..0e0fb6085466d9525049810c8b409a44b42a4519 100644 (file)
@@ -79,8 +79,9 @@ static ClientInfo *
 clientdbAdd(const Ip::Address &addr)
 {
     ClientInfo *c;
-    char *buf = new char[MAX_IPSTRLEN];
+    char *buf = static_cast<char*>(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);
 }