No double deref luau (#11448) 62fcec60de

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
This commit is contained in:
luigi-rosso
2026-01-13 07:13:04 +00:00
parent 46cd7a7406
commit 768aacd78d
18 changed files with 226 additions and 189 deletions

View File

@@ -513,7 +513,7 @@ end
ScriptedDrawable drawable;
// Create LuaState from ScriptingTest's VM state
LuaState luaState(L);
lua_State* luaState = L;
// Manually set the inits flag since we're not using ScriptAsset
// The inits flag indicates that the script has an init function
@@ -524,7 +524,7 @@ end
// ScriptingTest already left it there, so we can call scriptInit directly
// Call ScriptedObject::scriptInit directly to avoid addDirt which requires
// an artboard
CHECK(drawable.ScriptedObject::scriptInit(&luaState));
CHECK(drawable.ScriptedObject::scriptInit(luaState));
// Manually set implemented methods flags since we're not using ScriptAsset
// Check if advance function exists and set the flag
@@ -597,7 +597,7 @@ end
ScriptedLayout layout;
// Create LuaState from ScriptingTest's VM state
LuaState luaState(L);
lua_State* luaState = L;
// Manually set the inits flag since we're not using ScriptAsset
layout.implementedMethods(layout.implementedMethods() |
@@ -606,7 +606,7 @@ end
// scriptInit expects the factory function on the stack
// Call ScriptedObject::scriptInit directly to avoid addDirt which requires
// an artboard
CHECK(layout.ScriptedObject::scriptInit(&luaState));
CHECK(layout.ScriptedObject::scriptInit(luaState));
// Manually set implemented methods flags
// After scriptInit, the self table is stored in m_self
@@ -708,22 +708,22 @@ end
// Create LuaState from ScriptingTest's VM state
// Keep it in scope for the entire test since converter stores a pointer to
// it
LuaState luaState(L);
lua_State* luaState = L;
// Manually set the inits flag since we're not using ScriptAsset
converter->implementedMethods(converter->implementedMethods() |
(1 << 9)); // m_initsBit
// Verify LuaState is valid before using it
REQUIRE(luaState.state != nullptr);
REQUIRE(luaState.state == L);
REQUIRE(luaState != nullptr);
REQUIRE(luaState == L);
// scriptInit expects the factory function on the stack
// Verify stack state before calling scriptInit
REQUIRE(lua_gettop(L) == stackTop);
REQUIRE(lua_type(L, -1) == LUA_TFUNCTION);
REQUIRE(converter->ScriptedObject::scriptInit(&luaState));
REQUIRE(converter->ScriptedObject::scriptInit(luaState));
converter->addScriptedDirt(ComponentDirt::Bindings);
// Verify self() is valid before using it