diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2021-06-13 23:28:41 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2021-06-13 23:30:56 +0100 |
commit | fca21d56d38fd0ee394114074d980bdf7e06ff7f (patch) | |
tree | dc9c628c72bdfce4e96336cdbbab15d1f3f40718 | |
parent | 6e52bb7e651e7cbc55d915a4994b0f232c2966c2 (diff) | |
download | mlua-fca21d56d38fd0ee394114074d980bdf7e06ff7f.zip |
Check stack in entrypoint1 before pushing value to a stack
-rw-r--r-- | src/lua.rs | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -536,14 +536,18 @@ impl Lua { F: 'static + MaybeSend + Fn(&'callback Lua) -> Result<R>, { let cb = self.create_callback(Box::new(move |lua, _| func(lua)?.to_lua_multi(lua)))?; - match cb.call(()) { - Ok(res) => unsafe { self.push_value(res)? }, - Err(err) => unsafe { - self.push_value(Value::Error(err))?; - // This longjmp is undesired, but we cannot wrap it to a C - ffi::lua_error(self.state) - }, - } + let res = cb.call(()); + unsafe { + check_stack(self.state, 2)?; + match res { + Ok(res) => self.push_value(res)?, + Err(err) => { + self.push_value(Value::Error(err))?; + // This longjmp is undesired, but we cannot wrap it to a C + ffi::lua_error(self.state) + } + } + }; Ok(1) } |