Do not crash in release when accessing an AnyUserData
Also, don't bother asserting if the userdata has no metatable, just behave as though the userdata has no type. This should be impossible to trigger currently without the debug library, but it is not really that useful of an assert anyway.
This commit is contained in:
parent
f0775f4a1a
commit
4358034bbf
|
@ -420,22 +420,20 @@ impl<'lua> AnyUserData<'lua> {
|
|||
|
||||
lua.push_ref(&self.0);
|
||||
|
||||
rlua_debug_assert!(
|
||||
ffi::lua_getmetatable(lua.state, -1) != 0,
|
||||
"AnyUserData missing metatable"
|
||||
);
|
||||
|
||||
ffi::lua_rawgeti(
|
||||
lua.state,
|
||||
ffi::LUA_REGISTRYINDEX,
|
||||
lua.userdata_metatable::<T>()? as ffi::lua_Integer,
|
||||
);
|
||||
|
||||
if ffi::lua_rawequal(lua.state, -1, -2) == 0 {
|
||||
if ffi::lua_getmetatable(lua.state, -1) == 0 {
|
||||
Err(Error::UserDataTypeMismatch)
|
||||
} else {
|
||||
let res = func(&*get_userdata::<RefCell<T>>(lua.state, -3));
|
||||
res
|
||||
ffi::lua_rawgeti(
|
||||
lua.state,
|
||||
ffi::LUA_REGISTRYINDEX,
|
||||
lua.userdata_metatable::<T>()? as ffi::lua_Integer,
|
||||
);
|
||||
|
||||
if ffi::lua_rawequal(lua.state, -1, -2) == 0 {
|
||||
Err(Error::UserDataTypeMismatch)
|
||||
} else {
|
||||
func(&*get_userdata::<RefCell<T>>(lua.state, -3))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue