Skip to content

Commit d438c4b

Browse files
committed
Ensure array capacity only if index is larger than array length
1 parent ac189ac commit d438c4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Lua/LuaTable.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ public void Insert(int index, LuaValue value)
149149
}
150150

151151
var arrayIndex = index - 1;
152-
EnsureArrayCapacity(array.Length + 1);
152+
153+
if (index > array.Length)
154+
{
155+
EnsureArrayCapacity(array.Length + 1);
156+
}
153157

154158
if (arrayIndex != array.Length - 1)
155159
{

0 commit comments

Comments
 (0)