]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Allocate ClientInfo::hash.key using malloc() instead of new char[]
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 11 May 2013 00:16:48 +0000 (18:16 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Sat, 11 May 2013 00:16:48 +0000 (18:16 -0600)
because it is destroyed using free() instead of delete[].

Added ClientInfo construction/destruction debugging to find leaking objects.

src/client_db.cc

index ca09ac233aab86692bfff08e870e77aebe97f2d5..01aaf2edd28565e8800e7503e95d1f8d11ccc967 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
@@ -354,6 +355,7 @@ clientdbFreeItem(void *data)
     }
 #endif
 
+    debugs(77, 9, "ClientInfo destructed, this=" << c);
     memFree(c, MEM_CLIENT_INFO);
 }