summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-12-01 21:16:50 -0500
committerAdam <Adam@anope.org>2013-12-01 21:16:50 -0500
commitb5966cf99e2b1ffd578e0aa371803cb17013956f (patch)
treee8f678b15f30f1aa9ce6b3768218b619bac55170 /modules
parentfaab2c67937cf23ef87dfa0b8d0224bfabd61425 (diff)
Fix crash from loading exceptions with db_old and then unloading db_old
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/os_session.cpp5
-rw-r--r--modules/database/db_old.cpp10
2 files changed, 10 insertions, 5 deletions
diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp
index be003900d..8e210d5da 100644
--- a/modules/commands/os_session.cpp
+++ b/modules/commands/os_session.cpp
@@ -42,6 +42,11 @@ class MySessionService : public SessionService
public:
MySessionService(Module *m) : SessionService(m), Exceptions("Exception") { }
+ Exception *CreateException() anope_override
+ {
+ return new Exception();
+ }
+
void AddException(Exception *e) anope_override
{
this->Exceptions->push_back(e);
diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp
index 37405e308..c017eb681 100644
--- a/modules/database/db_old.cpp
+++ b/modules/database/db_old.cpp
@@ -1070,6 +1070,9 @@ static void LoadOper()
static void LoadExceptions()
{
+ if (!session_service)
+ return;
+
dbFILE *f = open_db_read("OperServ", "exception.db", 9);
if (f == NULL)
return;
@@ -1090,17 +1093,14 @@ static void LoadExceptions()
READ(read_int32(&time, f));
READ(read_int32(&expires, f));
- Exception *exception = new Exception();
+ Exception *exception = session_service->CreateException();
exception->mask = mask;
exception->limit = limit;
exception->who = who;
exception->time = time;
exception->expires = expires;
exception->reason = reason;
- if (session_service)
- session_service->AddException(exception);
- else
- delete exception;
+ session_service->AddException(exception);
}
close_db(f);