diff options
author | jbevain <jbevain@gmail.com> | 2011-04-04 21:18:36 +0400 |
---|---|---|
committer | jbevain <jbevain@gmail.com> | 2011-04-04 21:18:36 +0400 |
commit | fce46b334d256ffdc2e8d1a9b4c3087adc4d260c (patch) | |
tree | dec6d718d36e4305e8967a4c611f1791b2a56d0b /Mono.Collections.Generic | |
parent | 497cd0f3c516a07cbe8735397fadb6e07be68191 (diff) |
Always copy source array
Diffstat (limited to 'Mono.Collections.Generic')
-rw-r--r-- | Mono.Collections.Generic/ReadOnlyCollection.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Mono.Collections.Generic/ReadOnlyCollection.cs b/Mono.Collections.Generic/ReadOnlyCollection.cs index bd467c9..0b3fafb 100644 --- a/Mono.Collections.Generic/ReadOnlyCollection.cs +++ b/Mono.Collections.Generic/ReadOnlyCollection.cs @@ -57,8 +57,7 @@ namespace Mono.Collections.Generic { if (array == null) throw new ArgumentNullException (); - this.items = array; - this.size = array.Length; + Initialize (array, array.Length); } public ReadOnlyCollection (Collection<T> collection) @@ -66,8 +65,14 @@ namespace Mono.Collections.Generic { if (collection == null) throw new ArgumentNullException (); - this.items = collection.items; - this.size = collection.size; + Initialize (collection.items, collection.size); + } + + void Initialize (T [] items, int size) + { + this.items = new T [size]; + Array.Copy (items, 0, this.items, 0, size); + this.size = size; } internal override void Grow (int desired) |