Check that Lua state is non-null in init_from_ptr()

This commit is contained in:
Alex Orlenko 2022-08-01 15:19:46 +01:00
parent ee32dc33f3
commit 5330b900fd
No known key found for this signature in database
GPG key ID: 4C150C250863B96D

View file

@ -497,6 +497,7 @@ impl Lua {
/// by calling this function again.
#[allow(clippy::missing_safety_doc)]
pub unsafe fn init_from_ptr(state: *mut ffi::lua_State) -> Lua {
assert!(!state.is_null(), "Lua state is NULL");
let main_state = get_main_state(state).unwrap_or(state);
let main_state_top = ffi::lua_gettop(main_state);