Add alignment check for userdata

This commit is contained in:
William Venner 2022-02-10 20:10:21 +00:00
parent 87d25a2205
commit 76eedec62a
1 changed files with 2 additions and 0 deletions

View File

@ -576,6 +576,8 @@ impl LuaState {
let ptr = (LUA_SHARED.lua_newuserdata)(*self, std::mem::size_of::<T>()) as *mut T;
debug_assert_eq!(ptr as usize % std::mem::align_of::<T>(), 0, "Lua userdata is unaligned!");
if has_metatable {
self.push_value(-2);
self.set_metatable(-2);