Repository navigation
lua52-sys: fix lua_Debug layout and lua_getctx signature to match - #227
Open
argusSecurityBot wants to merge 1 commit into
Open
argusSecurityBot wants to merge 1 commit into
argusSecurityBot wants to merge 1 commit into
Conversation
… 5.2 ABI The #[repr(C)] lua_Debug binding omitted the trailing private i_ci field that Lua 5.2's real struct ends with (struct CallInfo *i_ci). The struct was 120 bytes where C's is 128, so lua_getstack's store to ar->i_ci wrote 8 bytes past a Rust-sized lua_Debug. Add the trailing field; the struct is now 128 bytes, matching sizeof(lua_Debug) in lua.h. lua_getctx was declared taking ctx by value (c_int) where the C function is int lua_getctx(lua_State *L, int *ctx) and writes *ctx. Passing an integer made C treat it as an address and store through it. Declare ctx as *mut c_int.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The #[repr(C)] lua_Debug binding omitted the trailing private i_ci field that Lua 5.2's real struct ends with (struct CallInfo *i_ci). The struct was 120 bytes where C's is 128, so lua_getstack's store to ar->i_ci wrote 8 bytes past a Rust-sized lua_Debug. Add the trailing field; the struct is now 128 bytes, matching sizeof(lua_Debug) in lua.h.
lua_getctx was declared taking ctx by value (c_int) where the C function is int lua_getctx(lua_State *L, int *ctx) and writes *ctx. Passing an integer made C treat it as an address and store through it. Declare ctx as *mut c_int.