summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-12 01:44:00 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-12 01:44:00 +0000
commitc42a4ace0281ee6a89f6df2af3b15563ffe98064 (patch)
treebe259ea3e6965c409a454e3ddd89fc0f6845456e /src/inspircd.cpp
parentb2c011a23adfb2472f51a4c18bf8f29e6e37bb04 (diff)
Honking great memory leak fixed that's been there since the early alphas :/
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1366 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index cf68705cb..f11386a26 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -2229,9 +2229,9 @@ void kill_link(userrec *user,const char* r)
log(DEBUG,"deleting user hash value %lu",(unsigned long)user);
if (user->fd > -1)
fd_ref_table[user->fd] = NULL;
- delete user;
clientlist.erase(iter);
}
+ delete user;
}
void kill_link_silent(userrec *user,const char* r)
@@ -2288,9 +2288,9 @@ void kill_link_silent(userrec *user,const char* r)
log(DEBUG,"deleting user hash value %lu",(unsigned long)user);
if (user->fd > -1)
fd_ref_table[user->fd] = NULL;
- delete user;
clientlist.erase(iter);
}
+ delete user;
}
@@ -2435,8 +2435,8 @@ userrec* ReHashNick(char* Old, char* New)
log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
- clientlist[New] = new userrec();
- clientlist[New] = oldnick->second;
+ userrec* olduser = oldnick->second;
+ clientlist[New] = olduser;
clientlist.erase(oldnick);
log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
@@ -2464,19 +2464,24 @@ void AddWhoWas(userrec* u)
if (iter == whowas.end())
{
- if (whowas.size() == WHOWAS_MAX)
+ if (whowas.size() >= WHOWAS_MAX)
{
for (user_hash::iterator i = whowas.begin(); i != whowas.end(); i++)
{
// 3600 seconds in an hour ;)
if ((i->second->signon)<(TIME-(WHOWAS_STALE*3600)))
{
+ // delete the old one
if (i->second) delete i->second;
+ // replace with new one
i->second = a;
log(DEBUG,"added WHOWAS entry, purged an old record");
return;
}
}
+ // no space left and user doesnt exist. Don't leave ram in use!
+ log(DEBUG,"Not able to update whowas (list at WHOWAS_MAX entries and trying to add new?), freeing excess ram");
+ delete a;
}
else
{
@@ -2514,6 +2519,8 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
// issue in earlier alphas/betas
if (iter != clientlist.end())
{
+ userrec* goner = iter->second;
+ delete goner;
clientlist.erase(iter);
}
@@ -2588,7 +2595,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
// irc server at once (or the irc server otherwise initiating this many connections, files etc)
// which for the time being is a physical impossibility (even the largest networks dont have more
// than about 10,000 users on ONE server!)
- if (socket > 65535)
+ if (socket > 65534)
{
kill_link(clientlist[tempnick],"Server is full");
return;