]> 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:46:58 +0000 (21:46 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 19 May 2013 03:46:58 +0000 (21:46 -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 c8456cebd8c0e2b31eb6fce4b2c2984c79b660af..e034b1323bcfe15434f7b77afbe48288a93cec9f 100644 (file)
@@ -72,8 +72,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
@@ -355,6 +356,7 @@ clientdbFreeItem(void *data)
     }
 #endif
 
+    debugs(77, 9, "ClientInfo destructed, this=" << c);
     memFree(c, MEM_CLIENT_INFO);
 }