Check stack in entrypoint1 before pushing value to a stack
This commit is contained in:
parent
6e52bb7e65
commit
fca21d56d3
12
src/lua.rs
12
src/lua.rs
|
@ -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 {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue