fix(LuaMod): Resolve stack indexing and sanitize params in StaticConstructObject#1245
fix(LuaMod): Resolve stack indexing and sanitize params in StaticConstructObject#1245500Byte wants to merge 2 commits into
Conversation
…#1149) Rewrites StaticConstructObject to use absolute stack indices and non-consuming logic. This resolves parameter misalignment issues when optional parameters are omitted or of incorrect types, which was causing crashes in production.
|
First of all, this code is AI generated, important to know, and the PR description itself kind of looks AI generated as well but I can't prove that so I'll give you the benefit of the doubt. Second, can you clarify (without AI) what the problem actually is ? Regarding InstanceGraph, and ExternalPackage; They were implemented as integers which are then cast to pointers to allow very advanced usage where the caller knows the address of these objects and would like to use these params even though we don't fully support it. |
What does this PR do?
Implements a C++ root-cause fix for memory corruption and access violations related to
StaticConstructObjectin the Lua API.The Problem
When passing parameters from Lua to
StaticConstructObject, the original code used implicit stack advancement to read each argument, which could cause incorrect values to be read if any parameter check failed early.The Solution
lua_gettop()+ positional checks (lua.is_userdata(N),lua_tointeger(L, N)).InstanceGraphandExternalPackageto reject invalid non-nil values instead of silently casting them.