Skip to content

Commit

Permalink
Merge pull request #82 from attilamolnar/insp12+rlinefix
Browse files Browse the repository at this point in the history
Fix potential crash in m_rline.cpp
  • Loading branch information
rburchell committed Apr 19, 2012
2 parents cb50878 + ce1ad5f commit 3fb86fa
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/modules/m_rline.cpp
Expand Up @@ -190,15 +190,14 @@ class ModuleRLine : public Module
RLineFactory *f;
bool MatchOnNickChange;
std::string RegexEngine;
bool usedinterface;

public:
ModuleRLine(InspIRCd* Me) : Module(Me)
ModuleRLine(InspIRCd* Me) : Module(Me), usedinterface(false)
{
mymodule = this;
OnRehash(NULL);

Me->Modules->UseInterface("RegularExpression");

// Create a new command
r = new CommandRLine(ServerInstance);
ServerInstance->AddCommand(r);
Expand All @@ -213,7 +212,8 @@ class ModuleRLine : public Module

virtual ~ModuleRLine()
{
ServerInstance->Modules->DoneWithInterface("RegularExpression");
if (usedinterface)
ServerInstance->Modules->DoneWithInterface("RegularExpression");
ServerInstance->XLines->DelAll("R");
ServerInstance->XLines->UnregisterFactory(f);
delete f;
Expand Down Expand Up @@ -262,6 +262,11 @@ class ModuleRLine : public Module
{
ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
rxengine = *i;
if (!usedinterface)
{
ServerInstance->Modules->UseInterface("RegularExpression");
usedinterface = true;
}
}
}
}
Expand Down Expand Up @@ -289,6 +294,11 @@ class ModuleRLine : public Module
{
ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
rxengine = mod;
if (!usedinterface)
{
ServerInstance->Modules->UseInterface("RegularExpression");
usedinterface = true;
}
}
}
}
Expand Down

0 comments on commit 3fb86fa

Please sign in to comment.