Skip to content

Commit 20164ce

Browse files
committed
Added some missing null pointer checks
1 parent ec2aa3c commit 20164ce

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

MTA10_Server/mods/deathmatch/logic/CSettings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ CXMLNode* CSettings::Get ( const char *szLocalResource, const char *szSetting, b
184184
bDeleteNode = false;
185185

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

189190
// Get the actual resource name from the specified setting, and get the resource class
190191
if ( !GetResourceName ( szSetting, szQueryResource, MAX_RESOURCE_LENGTH - 1 ) ) {

MTA10_Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Player.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ int CLuaFunctionDefs::ShowCursor ( lua_State* luaVM )
178178

179179
if ( !argStream.HasErrors () )
180180
{
181-
CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
182-
if ( CStaticFunctionDefinitions::ShowCursor ( pPlayer, luaMain, bShow, bToggleControls ) )
181+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
182+
if ( pLuaMain && CStaticFunctionDefinitions::ShowCursor ( pPlayer, pLuaMain, bShow, bToggleControls ) )
183183
{
184184
lua_pushboolean ( luaVM, true );
185185
return 1;

MTA10_Server/mods/deathmatch/logic/lua/LuaCommon.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void lua_pushelement ( lua_State* luaVM, CElement* pElement )
5353
{
5454
const char* szClass = NULL;
5555
CLuaMain* pLuaMain = g_pGame->GetLuaManager ()->GetVirtualMachine ( luaVM );
56-
if ( pLuaMain->IsOOPEnabled () )
56+
if ( pLuaMain && pLuaMain->IsOOPEnabled () )
5757
szClass = CLuaClassDefs::GetElementClass ( pElement );
5858

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)