Skip to content

Commit

Permalink
fix segfaults due to access to dead lua states (coroutines)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Jan 29, 2025
1 parent 39fcc10 commit 41dfcad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/logic/scripting/lua/lua_util.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "lua_util.hpp"
#include "lua_engine.hpp"

#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -228,6 +229,7 @@ static std::shared_ptr<std::string> create_lambda_handler(State* L) {
return std::shared_ptr<std::string>(
new std::string(name),
[=](std::string* name) {
auto L = lua::get_main_state();
requireglobal(L, LAMBDAS_TABLE);
pushnil(L);
setfield(L, *name);
Expand All @@ -240,6 +242,7 @@ static std::shared_ptr<std::string> create_lambda_handler(State* L) {
runnable lua::create_runnable(State* L) {
auto funcptr = create_lambda_handler(L);
return [=]() {
auto L = lua::get_main_state();
if (!get_from(L, LAMBDAS_TABLE, *funcptr, false))
return;
call_nothrow(L, 0, 0);
Expand Down

0 comments on commit 41dfcad

Please sign in to comment.