From 3e913d49ecb19fb252f850c4b52674062d21ddbb Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 10 Sep 2011 11:51:29 +0200 Subject: [PATCH] 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 --- main.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.h b/main.h index 8e77373d..4967be5e 100644 --- a/main.h +++ b/main.h @@ -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(); \