Skip to content
Browse files

Fix crash in CClientPed::IsReloadingWeapon

  • Loading branch information...
botder committed Jun 23, 2019
1 parent 1f611e8 commit 627b39d9d40bdcfce139abec97a800a855cd7cc6
Showing with 4 additions and 1 deletion.
  1. +4 −1 Client/mods/deathmatch/logic/CClientPed.cpp
@@ -5973,7 +5973,10 @@ bool CClientPed::ReloadWeapon()

bool CClientPed::IsReloadingWeapon()
return GetWeapon()->GetState() == WEAPONSTATE_RELOADING;
if (CWeapon* weapon = GetWeapon(); weapon != nullptr)
return weapon->GetState() == WEAPONSTATE_RELOADING;
return false;

bool CClientPed::ShouldBeStealthAiming()

2 comments on commit 627b39d


This comment has been minimized.

Copy link

replied Jun 25, 2019

When was this crash introduced?


This comment has been minimized.

Copy link

replied Jun 25, 2019

When was this crash introduced?

It has probably always been there (due to lacking a null check where other related functions have one), waiting to be invoked by a certain (dodgy) script.

Link to a case:

The stack was:

0028edd8 6ca54554 90e4579a 0ef1bef0 22de0048 client!CClientPed::IsReloadingWeapon+0x3d
0028eec4 6cace468 0ef1bef0 0ef1bef0 2f231d88 client!CLuaPedDefs::IsPedReloadingWeapon+0x184
0028eedc 6cae10b5 0ef1bef0 00000110 00000001 client!luaD_precall+0x278
0028efec 6cacdeec 0ef1bef0 00000001 0ef1bef0 client!luaV_execute+0xff5
0028f000 6cac5a33 0ef1bef0 2f231d28 ffffffff client!luaD_call+0x4c
0028f014 6cace622 0ef1bef0 0028f0d4 00000000 client!f_call+0x13
0028f080 6cace07a 0ef1bef0 6cac5a20 0028f0d4 client!luaD_rawrunprotected+0x52
0028f0ac 6cac6580 01f1bef0 6cac5a20 0028f0d4 client!luaD_pcall+0x3a
0028f0dc 6c9ee31f 0ef1bef0 00000005 ffffffff client!lua_pcall+0xa0
0028f108 6c9c9b16 0ef1bef0 00000005 ffffffff client!CLuaMain::PCall+0x5f
0028f170 6c980178 238aed08 3300adbc 00000000 client!CLuaArguments::Call+0xe6
0028f184 6c980e8e 0028f424 90e44a3a 6403d358 client!CMapEvent::Call+0x18
0028f364 6c911034 6403d358 0028f424 0eecfc80 client!CMapEventManager::Call+0x45e
0028f3bc 6c9985d5 6403d358 0028f424 00000001 client!CClientEntity::CallEvent+0x84
0028f8ac 6c923f41 00000051 0028f924 0028f8e0 client!CPacketHandler::ProcessPacket+0xdf5
0028f8bc 6e99629f 00000051 0028f924 062b8370 client!CClientGame::StaticProcessPacket+0x51
WARNING: Stack unwind information not available. Following frames may be wrong.
0028f8e0 6e995255 00000051 0028f924 942bd42a netc+0x2629f
0028f9a4 6c91b5b2 0b88d420 0b88d330 0b88d301 netc+0x25255
0028f9b8 6c91bb80 00000001 90e4424e 0b88d330 client!CClientGame::DoPulses2+0x82
0028fb10 6c91b253 90e442d6 01b0cdd8 01bbca80 client!CClientGame::DoPulses+0x500
0028fb88 707e72a3 01b0cdd8 051a6fe0 707a4954 client!CClientGame::DoPulsePostFrame+0x5c3
0028fb94 707a4954 9b0589ef 00000001 051a6fe0 core!CModManager::DoPulsePostFrame+0x53
0028fc84 7083b00a 9b0589a3 06d4a118 00000000 core!CCore::DoPostFramePulse+0x774
0028fcc8 708419b0 051a6fe0 04999018 007f99b0 core!CDirect3DEvents9::OnPresent+0x16a
0028fd2c 007f9b12 06d4a118 00000000 00000000 core!CProxyDirect3DDevice9::Present+0x30
0028fd44 04999018 007f99b0 00000000 007fb1c3 gta_sa+0x3f9b12
00000000 00000000 00000000 00000000 00000000 0x4999018

After further investigation it seemed like this:

it's crashing because of the null pointer m_pPlayerPed - CClientPed::IsReloadingWeapon() doesn't check if GetWeapon() returns NULL

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