Skip to content
Permalink
Browse files

Added some missing null pointer checks

  • Loading branch information...
ccw808 committed Oct 30, 2015
1 parent ec2aa3c commit 20164ceb823cce504bc95f775cc49e94485001fb
@@ -184,7 +184,8 @@ CXMLNode* CSettings::Get ( const char *szLocalResource, const char *szSetting, b
bDeleteNode = false;

// Get the temporary storage node associated with this resource
CXMLNode *pStorage = m_pResourceManager->GetResource ( szLocalResource )->GetStorageNode ();
CResource* pLocalResource = m_pResourceManager->GetResource ( szLocalResource );
CXMLNode* pStorage = pLocalResource ? pLocalResource->GetStorageNode () : nullptr;

// Get the actual resource name from the specified setting, and get the resource class
if ( !GetResourceName ( szSetting, szQueryResource, MAX_RESOURCE_LENGTH - 1 ) ) {
@@ -178,8 +178,8 @@ int CLuaFunctionDefs::ShowCursor ( lua_State* luaVM )

if ( !argStream.HasErrors () )
{
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( CStaticFunctionDefinitions::ShowCursor ( pPlayer, luaMain, bShow, bToggleControls ) )
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
if ( pLuaMain && CStaticFunctionDefinitions::ShowCursor ( pPlayer, pLuaMain, bShow, bToggleControls ) )
{
lua_pushboolean ( luaVM, true );
return 1;
@@ -53,7 +53,7 @@ void lua_pushelement ( lua_State* luaVM, CElement* pElement )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetElementClass ( pElement );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( ID.Value () ) );
@@ -69,7 +69,7 @@ void lua_pushacl ( lua_State* luaVM, CAccessControlList* pACL )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetACLClass ( pACL );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pACL->GetScriptID () ) );
@@ -80,7 +80,7 @@ void lua_pushaclgroup ( lua_State* luaVM, CAccessControlListGroup* pGroup )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetACLGroupClass ( pGroup );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pGroup->GetScriptID () ) );
@@ -91,7 +91,7 @@ void lua_pushaccount ( lua_State* luaVM, CAccount* pAccount )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetAccountClass ( pAccount );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pAccount->GetScriptID () ) );
@@ -102,7 +102,7 @@ void lua_pushresource ( lua_State* luaVM, CResource* pResource )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetResourceClass ( pResource );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pResource->GetScriptID () ) );
@@ -113,7 +113,7 @@ void lua_pushtextdisplay ( lua_State* luaVM, CTextDisplay* pDisplay )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetTextDisplayClass ( pDisplay );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pDisplay->GetScriptID () ) );
@@ -124,7 +124,7 @@ void lua_pushtextitem ( lua_State* luaVM, CTextItem* pItem )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetTextItemClass ( pItem );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pItem->GetScriptID () ) );
@@ -135,7 +135,7 @@ void lua_pushtimer ( lua_State* luaVM, CLuaTimer* pTimer )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetTimerClass ( pTimer );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pTimer->GetScriptID () ) );
@@ -146,7 +146,7 @@ void lua_pushxmlnode ( lua_State* luaVM, CXMLNode* pElement )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetXmlNodeClass ( pElement );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pElement->GetID () ) );
@@ -157,7 +157,7 @@ void lua_pushban ( lua_State* luaVM, CBan* pBan )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetBanClass ( pBan );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pBan->GetScriptID () ) );
@@ -168,7 +168,7 @@ void lua_pushquery ( lua_State* luaVM, CDbJobData* pJobData )
{
const char* szClass = NULL;
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
if ( pLuaMain->IsOOPEnabled () )
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
szClass = CLuaClassDefs::GetQueryClass ( pJobData );

lua_pushobject ( luaVM, szClass, ( void* ) reinterpret_cast < unsigned int * > ( pJobData->GetId() ) );

0 comments on commit 20164ce

Please sign in to comment.
You can’t perform that action at this time.