Skip to content

Commit d1cfe13

Browse files
committed
修正:访问来自非native父类的property时检查有效性 Tencent#661
1 parent ffdcd0f commit d1cfe13

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,23 @@ static void GetFieldInternal(lua_State* L)
10011001
lua_pushvalue(L, 2);
10021002
Type = lua_rawget(L, -2);
10031003
bCached = Type != LUA_TNIL;
1004+
// check cached property from non-native class
1005+
if (bCached && !Field->OuterClass->IsNative())
1006+
{
1007+
auto Ptr = lua_touserdata(L, -1);
1008+
if (Ptr)
1009+
{
1010+
auto Property = static_cast<TSharedPtr<UnLua::ITypeOps>*>(Ptr);
1011+
if (Property && Property->IsValid())
1012+
{
1013+
auto PropertyDesc = static_cast<FPropertyDesc*>((*Property).Get());
1014+
if (!PropertyDesc->IsValid())
1015+
{
1016+
bCached = false;
1017+
}
1018+
}
1019+
}
1020+
}
10041021
if (!bCached)
10051022
{
10061023
lua_pop(L, 1);

0 commit comments

Comments
 (0)