diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-17 13:54:53 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-04-17 13:54:53 +0000 |
commit | 2dfc384cde46ba63ed7c2f4420712596096123ca (patch) | |
tree | 0427aad7d9f9c1655adb4022dc3c2c32ecb626d0 /src/modes/cmode_k.cpp | |
parent | c6f1e7997d846cabe33bb031d9d5fcf0790b83fa (diff) |
Fix SetModeParam to use std::string and handle edge cases.
Previously, changing the vaule of a mode could require 3 calls to SetMode and SetModeParam.
This also fixes memory leaks caused by the strdup() not always being paired with a free().
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11307 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modes/cmode_k.cpp')
-rw-r--r-- | src/modes/cmode_k.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index f2afb9ac0..a7c491aa5 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -94,20 +94,16 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, s if (parameter.rfind(' ') != std::string::npos) return MODEACTION_DENY; - /* must first unset if we are changing the key, otherwise it will be ignored */ - if (exists && adding) - channel->SetMode('k', false); - - /* must run setmode always, to process the change */ - channel->SetMode('k', adding); - if (adding) { std::string ckey; ckey.assign(parameter, 0, 32); parameter = ckey; - /* running this does not run setmode, despite the third parameter */ - channel->SetModeParam('k', parameter.c_str(), true); + channel->SetMode('k', parameter); + } + else + { + channel->SetMode('k', ""); } return MODEACTION_ALLOW; } |