diff --git a/OpenRA.Mods.Cnc/FileFormats/XccGlobalDatabase.cs b/OpenRA.Mods.Cnc/FileFormats/XccGlobalDatabase.cs index 0fc6442b2a..fd7dd92f34 100644 --- a/OpenRA.Mods.Cnc/FileFormats/XccGlobalDatabase.cs +++ b/OpenRA.Mods.Cnc/FileFormats/XccGlobalDatabase.cs @@ -28,15 +28,16 @@ namespace OpenRA.Mods.Cnc.FileFormats while (s.Peek() > -1) { var count = s.ReadInt32(); + var chars = new List(); for (var i = 0; i < count; i++) { - var chars = new List(); byte c; // Read filename while ((c = s.ReadUInt8()) != 0) chars.Add((char)c); entries.Add(new string(chars.ToArray())); + chars.Clear(); // Skip comment while ((c = s.ReadUInt8()) != 0) { } diff --git a/OpenRA.Mods.Cnc/FileFormats/XccLocalDatabase.cs b/OpenRA.Mods.Cnc/FileFormats/XccLocalDatabase.cs index 1459c5e5b8..1fb1f3a02f 100644 --- a/OpenRA.Mods.Cnc/FileFormats/XccLocalDatabase.cs +++ b/OpenRA.Mods.Cnc/FileFormats/XccLocalDatabase.cs @@ -26,14 +26,15 @@ namespace OpenRA.Mods.Cnc.FileFormats var reader = new BinaryReader(s); var count = reader.ReadInt32(); Entries = new string[count]; + var chars = new List(); for (var i = 0; i < count; i++) { - var chars = new List(); char c; while ((c = reader.ReadChar()) != 0) chars.Add(c); Entries[i] = new string(chars.ToArray()); + chars.Clear(); } }