Permalink
Browse files

CModule::OnMode(): Fix a stupid NULL pointer dereference

When joining a channel, OnMode() (via SetModes()) was called with pOpNick ==
NULL. This bad pointer was turned into a reference and given to modules.

This bug exists since 2008 when the OnMode() module call was added. It wasn't
noticed before because apparently no module used this CNick argument before.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent 2b51222 commit 8ffab186b4f13e38898984d475ee104fcc0d7ea7 @psychon psychon committed Dec 6, 2012
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/Chan.cpp
View
@@ -332,15 +332,17 @@ void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
break;
}
- bool bNoChange;
- if (bList) {
- bNoChange = false;
- } else if (bAdd) {
- bNoChange = HasMode(uMode) && GetModeArg(uMode) == sArg;
- } else {
- bNoChange = !HasMode(uMode);
+ if (pOpNick) {
+ bool bNoChange;
+ if (bList) {
+ bNoChange = false;
+ } else if (bAdd) {
+ bNoChange = HasMode(uMode) && GetModeArg(uMode) == sArg;
+ } else {
+ bNoChange = !HasMode(uMode);
+ }
+ NETWORKMODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
}
- NETWORKMODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
if (!bList) {
(bAdd) ? AddMode(uMode, sArg) : RemMode(uMode);

0 comments on commit 8ffab18

Please sign in to comment.