diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-14 21:29:39 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-14 21:29:39 +0000 |
commit | fadc61f89e3c914424fdd37333ff356370d54d24 (patch) | |
tree | 0ac883428d87b62f0ad0e941ef4e37a7bf6ed94b | |
parent | 711787b54d8b57ace877b09587f368cee5553b70 (diff) |
Fixed crash caused by r2732 caused by adding someone to the exception list
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2756 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/services.h | 2 | ||||
-rw-r--r-- | src/core/db_plain.cpp | 2 | ||||
-rw-r--r-- | src/core/os_session.c | 2 | ||||
-rw-r--r-- | src/sessions.c | 5 |
4 files changed, 6 insertions, 5 deletions
diff --git a/include/services.h b/include/services.h index 244377419..adc906a98 100644 --- a/include/services.h +++ b/include/services.h @@ -1129,7 +1129,7 @@ struct sxline_ { struct exception_ { char *mask; /* Hosts to which this exception applies */ int limit; /* Session limit for exception */ - std::string who; /* Nick of person who added the exception */ + char *who; /* Nick of person who added the exception */ char *reason; /* Reason for exception's addition */ time_t time; /* When this exception was added */ time_t expires; /* Time when it expires. 0 == no expiry */ diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 65eee0d3a..564cd9a35 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -481,7 +481,7 @@ static void LoadOperInfo(const std::vector<std::string> ¶ms) exceptions = static_cast<Exception *>(srealloc(exceptions, sizeof(Exception) * nexceptions)); exceptions[nexceptions - 1].mask = sstrdup(params[1].c_str()); exceptions[nexceptions - 1].limit = atol(params[2].c_str()); - exceptions[nexceptions - 1].who = params[3]; + exceptions[nexceptions - 1].who = sstrdup(params[3].c_str()); exceptions[nexceptions - 1].time = strtol(params[4].c_str(), NULL, 10); exceptions[nexceptions - 1].expires = strtol(params[5].c_str(), NULL, 10); exceptions[nexceptions - 1].reason = sstrdup(params[6].c_str()); diff --git a/src/core/os_session.c b/src/core/os_session.c index cff470e58..5bd5515e2 100644 --- a/src/core/os_session.c +++ b/src/core/os_session.c @@ -167,7 +167,7 @@ static int exception_view(User *u, const int index, int *sent_header) expire_left(u->nc, expirebuf, sizeof(expirebuf), exceptions[index].expires); - notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, index + 1, exceptions[index].mask, !exceptions[index].who.empty() ? exceptions[index].who.c_str() : "<unknown>", timebuf, expirebuf, exceptions[index].limit, exceptions[index].reason); + notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, index + 1, exceptions[index].mask, exceptions[index].who ? exceptions[index].who : "<unknown>", timebuf, expirebuf, exceptions[index].limit, exceptions[index].reason); return 1; } diff --git a/src/sessions.c b/src/sessions.c index c70cf821e..867373f27 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -266,6 +266,7 @@ void expire_exceptions() exceptions[i].mask); delete [] exceptions[i].mask; delete [] exceptions[i].reason; + delete [] exceptions[i].who; nexceptions--; memmove(exceptions + i, exceptions + i + 1, sizeof(Exception) * (nexceptions - i)); @@ -335,13 +336,13 @@ int exception_add(User * u, const char *mask, const int limit, } nexceptions++; - exceptions = static_cast<Exception *>(srealloc(exceptions, sizeof(Exception) * nexceptions)); + exceptions = new Exception[nexceptions]; exceptions[nexceptions - 1].mask = sstrdup(mask); exceptions[nexceptions - 1].limit = limit; exceptions[nexceptions - 1].reason = sstrdup(reason); exceptions[nexceptions - 1].time = time(NULL); - exceptions[nexceptions - 1].who = who; + exceptions[nexceptions - 1].who = sstrdup(who); exceptions[nexceptions - 1].expires = expires; exceptions[nexceptions - 1].num = nexceptions - 1; |