summaryrefslogtreecommitdiff
path: root/src/serde/ser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/serde/ser.rs')
-rw-r--r--src/serde/ser.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/serde/ser.rs b/src/serde/ser.rs
index 4b774cb..4c6423c 100644
--- a/src/serde/ser.rs
+++ b/src/serde/ser.rs
@@ -9,7 +9,7 @@ use crate::lua::Lua;
use crate::string::String;
use crate::table::Table;
use crate::types::Integer;
-use crate::util::{check_stack, StackGuard};
+use crate::util::{check_stack, protect_lua, StackGuard};
use crate::value::{ToLua, Value};
/// A struct for serializing Rust values into Lua values.
@@ -318,12 +318,14 @@ impl<'lua> ser::SerializeSeq for SerializeVec<'lua> {
let value = lua.to_value_with(value, self.options)?;
unsafe {
let _sg = StackGuard::new(lua.state);
- check_stack(lua.state, 6)?;
+ check_stack(lua.state, 5)?;
lua.push_ref(&self.table.0);
lua.push_value(value)?;
let len = ffi::lua_rawlen(lua.state, -2) as Integer;
- ffi::safe::lua_rawseti(lua.state, -2, len + 1)
+ protect_lua(lua.state, 2, 0, |state| {
+ ffi::lua_rawseti(state, -2, len + 1);
+ })
}
}