summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-21 17:41:03 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-21 17:41:03 +0200
commit822f3f13f18b7e79d5740416f9417dabb9296859 (patch)
tree7cada807d9cb04b300b5974321d28c18b9d5e3d7
parent6e79197210e58d69e7bd512d0b5569c4cb06f3e5 (diff)
m_filter Fix memory leak on unload
-rw-r--r--src/modules/m_filter.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 86ef0d4f6..25941e5d8 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -165,6 +165,8 @@ class ImplFilter : public FilterResult
class ModuleFilter : public Module
{
+ void FreeFilters();
+
public:
CommandFilter filtcommand;
dynamic_reference<RegexFactory> RegexEngine;
@@ -178,6 +180,7 @@ class ModuleFilter : public Module
ModuleFilter();
void init();
+ CullResult cull();
ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list);
FilterResult* FilterMatch(User* user, const std::string &text, int flags);
bool DeleteFilter(const std::string &freeform);
@@ -304,6 +307,20 @@ void ModuleFilter::init()
OnRehash(NULL);
}
+CullResult ModuleFilter::cull()
+{
+ FreeFilters();
+ return Module::cull();
+}
+
+void ModuleFilter::FreeFilters()
+{
+ for (std::vector<ImplFilter>::const_iterator i = filters.begin(); i != filters.end(); ++i)
+ delete i->regex;
+
+ filters.clear();
+}
+
ModResult ModuleFilter::OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (!IS_LOCAL(user))