diff --git a/src/logic/scripting/lua/lua_util.cpp b/src/logic/scripting/lua/lua_util.cpp index 842c7859..d008cf45 100644 --- a/src/logic/scripting/lua/lua_util.cpp +++ b/src/logic/scripting/lua/lua_util.cpp @@ -270,12 +270,13 @@ scripting::common_func lua::create_lambda(State* L) { return [=](const std::vector& args) -> dv::value { if (!get_from(L, LAMBDAS_TABLE, *funcptr, false)) return nullptr; - int top = gettop(L) + 1; + int top = gettop(L) - 1; for (const auto& arg : args) { pushvalue(L, arg); } if (call(L, args.size(), 1)) { int nres = gettop(L) - top; + assert(nres >= 0); if (nres) { auto result = tovalue(L, -1); pop(L, 1 + nres);