diff options
author | Redwarx008 <50837890+Redwarx008@users.noreply.github.com> | 2023-03-26 21:14:08 +0800 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-30 19:21:14 +0200 |
commit | 493e39860dd5648fc0886b3e59772938158eedab (patch) | |
tree | 344bf9e1b223f47f5e01f0cad332ad07a8bb40ef /modules | |
parent | fe71d33033d178f7c437938313a213746f3662c3 (diff) |
C#: Fix Array.AddRange index out of bounds
Fix Array.AddRange index out of bounds
(cherry picked from commit eb1fb254a649efe128a3d993b7bd31486e9356e1)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index 8598c32760..5163ea5113 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -554,6 +554,7 @@ namespace Godot.Collections // instead of growing it as we add items. if (collection.TryGetNonEnumeratedCount(out int count)) { + int oldCount = Count; Resize(Count + count); using var enumerator = collection.GetEnumerator(); @@ -561,7 +562,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { enumerator.MoveNext(); - this[count + i] = Variant.From(enumerator.Current); + this[oldCount + i] = Variant.From(enumerator.Current); } return; @@ -1578,6 +1579,7 @@ namespace Godot.Collections // instead of growing it as we add items. if (collection.TryGetNonEnumeratedCount(out int count)) { + int oldCount = Count; Resize(Count + count); using var enumerator = collection.GetEnumerator(); @@ -1585,7 +1587,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { enumerator.MoveNext(); - this[count + i] = enumerator.Current; + this[oldCount + i] = enumerator.Current; } return; |