diff --git a/hlua/src/rust_tables.rs b/hlua/src/rust_tables.rs index ffcf3adb..2aac749b 100755 --- a/hlua/src/rust_tables.rs +++ b/hlua/src/rust_tables.rs @@ -133,8 +133,18 @@ impl<'lua, L, V> LuaRead for Vec } }; - let value: V = - LuaRead::lua_read_at_position(&mut me, -1).ok().unwrap(); + let value = { + let maybe_value: Option = + LuaRead::lua_read_at_position(&mut me, -1).ok(); + match maybe_value { + None => { + // Cleaning up after ourselves + unsafe { ffi::lua_pop(me.as_mut_lua().0, 2) }; + return Err(me) + } + Some(v) => v, + } + }; unsafe { ffi::lua_pop(me.as_mut_lua().0, 1) };