From 2d8e53b0f986dcb905180714fb37b44e6d04f405 Mon Sep 17 00:00:00 2001 From: William Venner Date: Tue, 4 Jan 2022 21:56:23 +0000 Subject: [PATCH] Hackfix for garrysmod-issues#5134 --- gmod/src/lua/lua_state.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index 55a05e4..c4fd819 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -239,7 +239,12 @@ impl LuaState { } pub unsafe fn lua_type_name(&self, lua_type_id: i32) -> Cow<'_, str> { + let hackfix = self.get_top(); // https://github.com/Facepunch/garrysmod-issues/issues/5134 + let type_str_ptr = (LUA_SHARED.lua_typename)(*self, lua_type_id); + + self.pop_n((self.get_top() - hackfix).max(0)); + let type_str = std::ffi::CStr::from_ptr(type_str_ptr); type_str.to_string_lossy() }