From 822f3f13f18b7e79d5740416f9417dabb9296859 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 21 Apr 2013 17:41:03 +0200 Subject: m_filter Fix memory leak on unload --- src/modules/m_filter.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/modules') 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 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::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)) -- cgit v1.2.3