1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 09:36:39 +02:00

Properly initialized new objects when needed so they don't contain garbage data.

Also, converted line endings in os_ignore_db from CR+LF to LF.

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1784 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
cyberbotx
2008-11-22 02:31:23 +00:00
parent 16e667a2ce
commit fb5d7d1815
10 changed files with 585 additions and 550 deletions
+22 -15
View File
@@ -6,6 +6,13 @@
class NickRequest
{
public:
NickRequest()
{
next = prev = NULL;
nick = passcode = email = NULL;
*password = 0;
requested = lastmail = 0;
}
NickRequest *next, *prev;
char *nick;
char *passcode;
@@ -20,16 +27,16 @@ class NickCore;
class NickAlias
{
public:
NickAlias()
{
next = prev = NULL;
nick = last_quit = last_realname = last_usermask = NULL;
time_registered = last_seen = 0;
status = 0;
nc = NULL;
u = NULL;
}
NickAlias()
{
next = prev = NULL;
nick = last_quit = last_realname = last_usermask = NULL;
time_registered = last_seen = 0;
status = 0;
nc = NULL;
u = NULL;
}
NickAlias *next, *prev;
char *nick; /* Nickname */
char *last_quit; /* Last quit message */
@@ -47,16 +54,16 @@ class NickAlias
class NickCore : public Extensible
{
public:
NickCore()
{
NickCore()
{
next = prev = NULL;
display = email = greet = url = NULL;
pass[0] = '\0';
icq = flags = 0;
language = accesscount = channelcount = 0;
lastmail = 0;
}
lastmail = 0;
}
NickCore *next, *prev;
char *display; /* How the nick is displayed */
+6
View File
@@ -620,6 +620,8 @@ static BanData *get_ban_data(Channel * c, User * u)
bd = new BanData;
bd->mask = sstrdup(mask);
bd->last_use = now;
for (int x = 0; x < TTB_SIZE; ++x)
bd->ttb[x] = 0;
bd->prev = NULL;
bd->next = c->bd;
@@ -662,6 +664,10 @@ static UserData *get_user_data(Channel * c, User * u)
} else {
user->ud = new UserData;
user->ud->last_use = time(NULL);
user->ud->lines = 0;
user->ud->last_start = 0;
user->ud->lastline = NULL;
user->ud->times = 0;
return user->ud;
}
}
+16 -1
View File
@@ -1527,11 +1527,13 @@ void chan_adduser2(User * user, Channel * c)
struct c_userlist *u;
u = new c_userlist;
u->prev = NULL;
u->next = c->users;
if (c->users)
c->users->prev = u;
c->users = u;
u->user = user;
u->ud = NULL;
c->usercount++;
if (get_ignore(user->nick) == NULL) {
@@ -1590,15 +1592,26 @@ Channel *chan_create(const char *chan, time_t ts)
if (debug)
alog("debug: Creating channel %s", chan);
/* Allocate pre-cleared memory */
c = new Channel;
strscpy(c->name, chan, sizeof(c->name));
list = &chanlist[HASH(c->name)];
c->prev = NULL;
c->next = *list;
if (*list)
(*list)->prev = c;
*list = c;
c->creation_time = ts;
c->topic = NULL;
*c->topic_setter = 0;
c->topic_time = 0;
c->mode = c->limit = 0;
c->key = c->redirect = c->flood = NULL;
c->bans = c->excepts = c->invites = NULL;
c->users = NULL;
c->usercount = 0;
c->bd = NULL;
c->server_modetime = c->chanserv_modetime = 0;
c->server_modecount = c->chanserv_modecount = c->bouncy_modes = c->topic_sync = 0;
/* Store ChannelInfo pointer in channel record */
c->ci = cs_findchan(chan);
if (c->ci)
@@ -1801,11 +1814,13 @@ Channel *join_user_update(User * user, Channel * chan, const char *name,
alog("debug: %s joins %s", user->nick, chan->name);
c = new u_chanlist;
c->prev = NULL;
c->next = user->chans;
if (user->chans)
user->chans->prev = c;
user->chans = c;
c->chan = chan;
c->status = 0;
chan_adduser2(user, chan);
+1
View File
@@ -78,6 +78,7 @@ int do_identify(User * u)
if ((res = enc_check_password(pass, ci->founderpass)) == 1) {
if (!is_identified(u, ci)) {
uc = new u_chaninfolist;
uc->prev = NULL;
uc->next = u->founder_chans;
if (u->founder_chans)
u->founder_chans->prev = uc;
+2
View File
@@ -229,6 +229,7 @@ Command *createCommand(const char *name, int (*func) (User * u),
c->help_param2 = NULL;
c->help_param3 = NULL;
c->help_param4 = NULL;
c->core = 0;
c->next = NULL;
c->mod_name = NULL;
c->service = NULL;
@@ -554,6 +555,7 @@ Message *createMessage(const char *name,
}
m->name = sstrdup(name);
m->func = func;
m->core = 0;
m->next = NULL;
return m;
}
+528 -528
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -58,8 +58,7 @@ void add_ignore(const char *nick, time_t delta)
snprintf(tmp, sizeof(tmp), "*!%s", nick);
mask = sstrdup(tmp);
}
/* We only got a nick.. */
/* We only got a nick.. */
} else {
snprintf(tmp, sizeof(tmp), "%s!*@*", nick);
mask = sstrdup(tmp);
+4 -2
View File
@@ -254,11 +254,13 @@ int add_session(const char *nick, const char *host, char *hostip)
session = new Session;
session->host = sstrdup(host);
list = &sessionlist[HASH(session->host)];
session->prev = NULL;
session->next = *list;
if (*list)
(*list)->prev = session;
*list = session;
session->count = 1;
session->hits = 0;
return 1;
}
@@ -773,7 +775,7 @@ int do_exception(User * u)
if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions)
&& (n1 != n2)) {
exception = new Exception;
exception = (Exception *)smalloc(sizeof(Exception));
memcpy(exception, &exceptions[n1], sizeof(Exception));
if (n1 < n2) {
@@ -788,7 +790,7 @@ int do_exception(User * u)
memmove(&exceptions[n2], exception, sizeof(Exception));
}
delete exception;
free(exception);
notice_lang(s_OperServ, u, OPER_EXCEPTION_MOVED,
exceptions[n1].mask, n1 + 1, n2 + 1);
+1
View File
@@ -75,6 +75,7 @@ Timeout *add_timeout(int delay, void (*code) (Timeout *), int repeat)
t->repeat = repeat;
t->next = timeouts;
t->prev = NULL;
t->data = NULL;
if (timeouts)
timeouts->prev = t;
timeouts = t;
+4 -2
View File
@@ -217,8 +217,10 @@ User::~User()
if (this->uid)
delete [] this->uid;
Anope_Free(this->realname);
delete [] this->hostip;
if (this->realname)
delete [] this->realname;
if (this->hostip)
delete [] this->hostip;
if (debug >= 2)
alog("debug: User::~User(): remove from channels");