From 5330b900fd2ddc8cdb7749aca82d66cef321c572 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 1 Aug 2022 15:19:46 +0100 Subject: [PATCH] Check that Lua state is non-null in init_from_ptr() --- src/lua.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua.rs b/src/lua.rs index f0e67c8..bfd3374 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -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);