From e5bb3ec652dd32ff2688b7c6f4bbb899d80663e8 Mon Sep 17 00:00:00 2001 From: Huoji's <1296564236@qq.com> Date: Thu, 19 Oct 2023 08:33:06 +0000 Subject: [PATCH] fix weapon name is nullptr crash bug --- csgo2/script_apis.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/csgo2/script_apis.cpp b/csgo2/script_apis.cpp index 2d63416..46e45ba 100644 --- a/csgo2/script_apis.cpp +++ b/csgo2/script_apis.cpp @@ -400,13 +400,14 @@ auto luaApi_GivePlayerWeapon(lua_State* luaVm) -> int { const auto playerIndex = lua_tointeger(luaVm, 1); const auto weaponName = lua_tostring(luaVm, 2); auto isSuccess = false; - ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { - if (playerController->m_bPawnIsAlive() == false) { - return; - } - isSuccess = - GameWeapons::ParseWeaponCommand(playerController, weaponName); - }); + if (weaponName != nullptr) { + ExcutePlayerAction(playerIndex, [&](CCSPlayerController* playerController) { + if (playerController->m_bPawnIsAlive() == false) { + return; + } + isSuccess = GameWeapons::ParseWeaponCommand(playerController, weaponName); + }); + } lua_pop(luaVm, 2); lua_pushboolean(luaVm, isSuccess); return 1;