From ce6764c87f83c3a74aae0fcd75547a368601b14a Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 21 Sep 2008 11:58:51 +0000 Subject: Fix bug discovered by Ankit, m_rline loaded without regex provider causes segfault because of missing check for NULL when querying RegexProvider interface git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10576 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_rline.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index e6340cc0f..7ea9d36b4 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -42,9 +42,12 @@ class CoreExport RLine : public XLine throw ModuleException("Regex engine not set or loaded!"); } - try { + try + { regex = RegexFactoryRequest(mymodule, rxengine, regexs).Create(); - } catch (ModuleException& ex) { + } + catch (ModuleException& ex) + { ServerInstance->SNO->WriteToSnoMask('x', "Bad regex: %s", ex.GetReason()); throw; } @@ -264,13 +267,16 @@ class ModuleRLine : public Module rxengine = 0; RegexEngine = newrxengine; modulelist* ml = ServerInstance->Modules->FindInterface("RegularExpression"); - for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i) + if (ml) { - std::string rxname = RegexNameRequest(this, *i).Send(); - if (rxname == newrxengine) + for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i) { - ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str()); - rxengine = *i; + std::string rxname = RegexNameRequest(this, *i).Send(); + if (rxname == newrxengine) + { + ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str()); + rxengine = *i; + } } } if (!rxengine) -- cgit v1.2.3