Don't use luaL_typename to get a static type name in Luau.

In Luau this function returns heap-allocated string rather than static string,
so accessing this value when Lua state is destroyed is UB.
Fixes #674
This commit is contained in:
Alex Orlenko
2026-01-27 14:07:47 +00:00
parent e67ae7f0de
commit 6bb7f09927
2 changed files with 6 additions and 2 deletions
+2 -1
View File
@@ -1211,7 +1211,8 @@ impl<L: FromLua, R: FromLua> FromLua for Either<L, R> {
Err(_) => match R::from_stack(idx, lua).map(Either::Right) {
Ok(r) => Ok(r),
Err(_) => {
let value_type_name = CStr::from_ptr(ffi::luaL_typename(lua.state(), idx));
let value_type_name =
CStr::from_ptr(ffi::lua_typename(lua.state(), ffi::lua_type(lua.state(), idx)));
Err(Error::FromLuaConversionError {
from: value_type_name.to_str().unwrap(),
to: Self::type_name(),