loadstring shouldn't accept bytecode
This commit is contained in:
parent
f5ddb00675
commit
ae3ecabcea
@ -1142,7 +1142,7 @@ LuaFunction LuaEngine::createRawFunction(lua_CFunction function) {
|
||||
LuaFunction LuaEngine::createFunctionFromSource(int handleIndex, char const* contents, size_t size, char const* name) {
|
||||
lua_checkstack(m_state, 2);
|
||||
|
||||
handleError(m_state, luaL_loadbuffer(m_state, contents, size, name));
|
||||
handleError(m_state, luaL_loadbufferx(m_state, contents, size, name, "t"));
|
||||
|
||||
pushHandle(m_state, handleIndex);
|
||||
lua_setupvalue(m_state, -2, 1);
|
||||
|
@ -108,9 +108,9 @@ LuaContext LuaRoot::createContext(StringList const& scriptPaths) {
|
||||
|
||||
auto handleIndex = newContext.handleIndex();
|
||||
auto engine = m_luaEngine.get();
|
||||
newContext.set("loadstring", m_luaEngine->createFunction([engine,handleIndex](String const& source, Maybe<String> const& name, Maybe<LuaValue> const& env) -> LuaFunction {
|
||||
newContext.set("loadstring", m_luaEngine->createFunction([engine, handleIndex](String const& source, Maybe<String> const& name, Maybe<LuaTable> const& env) -> LuaFunction {
|
||||
String functionName = name ? strf("loadstring: {}", *name) : "loadstring";
|
||||
return engine->createFunctionFromSource(handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr());
|
||||
return engine->createFunctionFromSource(env ? env->handleIndex() : handleIndex, source.utf8Ptr(), source.utf8Size(), functionName.utf8Ptr());
|
||||
}));
|
||||
|
||||
auto assets = Root::singleton().assets();
|
||||
|
Loading…
Reference in New Issue
Block a user