From 04d4c6410792e68722f56ccbab580bb989eded2d Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 5 Sep 2022 23:01:16 +0200 Subject: [PATCH] Squirrel: fix lambda capture for scheduled execute task Running command as FCVAR_GAMEDLL caused unpredictable behavior. --- r5dev/squirrel/sqscript.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r5dev/squirrel/sqscript.cpp b/r5dev/squirrel/sqscript.cpp index d28319ca..b9eb628b 100644 --- a/r5dev/squirrel/sqscript.cpp +++ b/r5dev/squirrel/sqscript.cpp @@ -246,9 +246,9 @@ void Script_Execute(const SQChar* code, SQCONTEXT context) { if (!ThreadInMainThread()) { - g_TaskScheduler->Dispatch([code, context]() + const string scode(code); + g_TaskScheduler->Dispatch([scode, context]() { - string scode(code); Script_Execute(scode.c_str(), context); }, 0);