diff --git a/src/util/mod.rs b/src/util/mod.rs index b69a867..4d07d3c 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -122,7 +122,7 @@ pub(crate) unsafe fn push_table( ) -> Result<()> { let narr: c_int = narr.try_into().unwrap_or(c_int::MAX); let nrec: c_int = nrec.try_into().unwrap_or(c_int::MAX); - if protect || narr >= const { 1 << 30 } || nrec >= const { 1 << 27 } { + if protect || narr >= const { 1 << 26 } || nrec >= const { 1 << 26 } { protect_lua!(state, 0, 1, |state| ffi::lua_createtable(state, narr, nrec)) } else { ffi::lua_createtable(state, narr, nrec); diff --git a/tests/table.rs b/tests/table.rs index 3d4f5ef..922da8d 100644 --- a/tests/table.rs +++ b/tests/table.rs @@ -61,6 +61,15 @@ fn test_table() -> Result<()> { Ok(()) } +#[test] +#[cfg(target_os = "linux")] // Linux allow overcommiting the memory (relevant for CI) +fn test_table_with_large_capacity() { + let lua = Lua::new(); + + let t = lua.create_table_with_capacity(1 << 26, 1 << 26); + assert!(t.is_ok()); +} + #[test] fn test_table_push_pop() -> Result<()> { let lua = Lua::new();