diff options
author | Emma Miler <27428383+emma-miler@users.noreply.github.com> | 2022-03-06 19:43:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-06 18:43:48 +0000 |
commit | 7f7ff36ad258e4cd01dd2fe8742befe3c73f4293 (patch) | |
tree | ded3442befc37cbbcb0c16e15e403ee6a13d1fce | |
parent | 218f0d1435c6b07f7cfb16cee0e962b91488c661 (diff) | |
download | NorthstarLauncher-7f7ff36ad258e4cd01dd2fe8742befe3c73f4293.tar.gz NorthstarLauncher-7f7ff36ad258e4cd01dd2fe8742befe3c73f4293.zip |
Fix a memory leak for `setupfunc` (#103)
-rw-r--r-- | NorthstarDedicatedTest/squirrel.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h index b01618f2..7801ada7 100644 --- a/NorthstarDedicatedTest/squirrel.h +++ b/NorthstarDedicatedTest/squirrel.h @@ -205,14 +205,20 @@ template <ScriptContext context> class SquirrelManager ClientSq_pushroottable(sqvm2); ClientSq_pushstring(sqvm2, funcname, -1); result = ClientSq_sq_get(sqvm2, -2); - ClientSq_pushroottable(sqvm2); + if (result != SQRESULT_ERROR) + { + ClientSq_pushroottable(sqvm2); + } } else if (context == ScriptContext::SERVER) { ServerSq_pushroottable(sqvm2); ServerSq_pushstring(sqvm2, funcname, -1); result = ServerSq_sq_get(sqvm2, -2); - ServerSq_pushroottable(sqvm2); + if (result != SQRESULT_ERROR) + { + ServerSq_pushroottable(sqvm2); + } } return result; } @@ -282,4 +288,4 @@ template <ScriptContext context> class SquirrelManager extern SquirrelManager<ScriptContext::CLIENT>* g_ClientSquirrelManager; extern SquirrelManager<ScriptContext::SERVER>* g_ServerSquirrelManager; -extern SquirrelManager<ScriptContext::UI>* g_UISquirrelManager;
\ No newline at end of file +extern SquirrelManager<ScriptContext::UI>* g_UISquirrelManager; |