diff --git a/sources/Data/Collections/ArrayList.uc b/sources/Data/Collections/ArrayList.uc index b52bfb7..18d5821 100644 --- a/sources/Data/Collections/ArrayList.uc +++ b/sources/Data/Collections/ArrayList.uc @@ -96,12 +96,15 @@ public final function ArrayList SetLength(int newLength) { local int i; - if (newLength < 0) { - return self; - } + if (newLength < 0) return self; + if (storedObjects.length == newLength) return self; + for (i = newLength; i < storedObjects.length; i += 1) { FreeItem(i); } + if (storedObjects.length <= 0) { + storedObjects[0] = none; + } storedObjects.length = newLength; return self; }