Skip to content

Commit bf3d5a2

Browse files
authored
fix(Lua): Correctly handle non-container Out-params in function calls
When a UFunction with an Out-parameter that is not a Struct or Array is called from Lua, a placeholder table is expected on the stack. The previous logic did not pop this placeholder table from the stack, leading to stack desynchronization on subsequent parameter processing and causing a crash or incorrect behavior. This commit adds the necessary to ensure the stack is correctly handled, resolving the issue.
1 parent fb22cb3 commit bf3d5a2

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

UE4SS/src/LuaType/LuaUObject.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ namespace RC::LuaType
199199

200200
if (!param_next->IsA<Unreal::FStructProperty>() && !param_next->IsA<Unreal::FArrayProperty>())
201201
{
202+
lua.discard_value();
202203
continue;
203204
}
204205
}

assets/Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ names. ([UE4SS #827](https://github.com/UE4SS-RE/RE-UE4SS/pull/827)
314314

315315
Fixed an error with Object properties causing stack corruption. ([UE4SS #939](https://github.com/UE4SS-RE/RE-UE4SS/pull/939)
316316

317+
Fixed a stack corruption issue when calling UFunctions from Lua with `Out` parameters that were not of type Struct or Array. ([UE4SS #942](https://github.com/UE4SS-RE/RE-UE4SS/pull/942))
318+
317319
### C++ API
318320
Fixed a crash caused by a race condition enabled by C++ mods using `UE4SS_ENABLE_IMGUI` in their constructor ([UE4SS #481](https://github.com/UE4SS-RE/RE-UE4SS/pull/481))
319321

0 commit comments

Comments
 (0)