From e01af22bacb14580bb7fa494fc3ee3f2b043f5a1 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sun, 9 Oct 2022 13:56:30 +0100 Subject: [PATCH] Update push_userdata_ref --- src/lua.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua.rs b/src/lua.rs index fc631d9..e7bfe42 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -2591,6 +2591,7 @@ impl Lua { pub(crate) unsafe fn push_userdata_ref(&self, lref: &LuaRef) -> Result> { self.push_ref(lref); if ffi::lua_getmetatable(self.state, -1) == 0 { + ffi::lua_pop(self.state, 1); return Err(Error::UserDataTypeMismatch); } let mt_ptr = ffi::lua_topointer(self.state, -1);