]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Segfault-causing typo (wrong var used for a loop, whoops)
[user/henk/code/inspircd.git] / src / users.cpp
index 83800e01d7e65d42a2f1765e9c79012a18c6f019..a0929d684f2c8f95c829dae8fe111d91e8a0d757 100644 (file)
@@ -107,16 +107,29 @@ userrec::userrec()
        server = (char*)FindServerNamePtr(Config->ServerName);
        reset_due = TIME;
        lines_in = fd = lastping = signon = idle_lastmsg = nping = registered = 0;
-       timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+       modebits = timeout = flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
        haspassed = dns_done = false;
        recvq = "";
        sendq = "";
        chans.clear();
        invites.clear();
+        chans.resize(MAXCHANS);
+        for (unsigned int n = 0; n < MAXCHANS; n++)
+        {
+               ucrec* x = new ucrec();
+               chans[n] = x;
+               x->channel = NULL;
+               x->uc_modes = 0;
+        }
 }
 
 userrec::~userrec()
 {
+       for (std::vector<ucrec*>::iterator n = chans.begin(); n != chans.end(); n++)
+       {
+               ucrec* x = (ucrec*)*n;
+               delete x;
+       }
 }
 
 void userrec::MakeHost(char* nhost)
@@ -518,6 +531,8 @@ void AddWhoWas(userrec* u)
                whowas_set* group = (whowas_set*)iter->second;
                if (group->size() > 10)
                {
+                       WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
+                       delete a;
                        group->pop_front();
                }
                WhoWasGroup *a = new WhoWasGroup(u);
@@ -614,11 +629,6 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
         clientlist[tempnick]->sendqmax = class_sqmax;
         clientlist[tempnick]->recvqmax = class_rqmax;
 
-        ucrec a;
-        a.channel = NULL;
-        a.uc_modes = 0;
-       clientlist[tempnick]->chans.resize(MAXCHANS);
-
        fd_ref_table[socket] = clientlist[tempnick];
        local_users.push_back(clientlist[tempnick]);