fix access violation on script command

running "script_client" from main menu would cause an access violation when attempting to access m_hVM from the CSquirrelVM instance for the client vm, which has not been created by this point
This commit is contained in:
rexx 2022-06-01 19:57:39 +01:00
parent 6ea1a8bebc
commit 5e58b7a5d3

View File

@ -243,7 +243,15 @@ SQBool Script_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar
//---------------------------------------------------------------------------------
void Script_Execute(const SQChar* code, SQCONTEXT context)
{
HSQUIRRELVM v = Script_GetContextObject(context)->GetVM();
CSquirrelVM* scriptVM = Script_GetContextObject(context);
if (!scriptVM)
{
Error(eDLL_T::ENGINE, "Attempted to run %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
HSQUIRRELVM v = scriptVM->GetVM();
if (!v)
{
Error(eDLL_T::ENGINE, "Attempted to run %s script while VM isn't initialized\n", SQVM_GetContextName(context));