assert that we have a user/network on module calls

exoa found a bug where OnClientDisconnected() was called with m_pUser = NULL
when a client disconnected before logging in which blows up further down the
road.

This stuff should *never* be called with NULL pointers, despite the if which it
has. E.g. the above case skipped user modules, but global modules where still
called with a NULL pointer which they didn't expect nor handle for
OnClientDisconnected().

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-09-10 11:51:29 +02:00
parent 1e3b73c7b2
commit 3e913d49ec
+3
View File
@@ -62,6 +62,7 @@
} while (false)
#define USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
assert(macUSER != NULL); \
if (macUSER) { \
CModules& UMods = macUSER->GetModules(); \
CIRCNetwork* pOldUNetwork = UMods.GetNetwork(); \
@@ -78,6 +79,8 @@
}
#define NETWORKMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
assert(macUSER != NULL); \
assert(macNETWORK != NULL); \
if (macNETWORK) { \
CModules& NMods = ((CIRCNetwork*)macNETWORK)->GetModules(); \
CClient* pOldNClient = NMods.GetClient(); \