dispose the memory stream and avoid the binary reader
This commit is contained in:
@@ -65,17 +65,17 @@ namespace OpenRA.FileSystem
|
|||||||
if (name.Length % 4 != 0)
|
if (name.Length % 4 != 0)
|
||||||
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
|
||||||
|
|
||||||
var ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
|
using (var ms = new MemoryStream(Encoding.ASCII.GetBytes(name)))
|
||||||
var reader = new BinaryReader(ms);
|
{
|
||||||
|
|
||||||
var len = name.Length >> 2;
|
var len = name.Length >> 2;
|
||||||
uint result = 0;
|
uint result = 0;
|
||||||
|
|
||||||
while (len-- != 0)
|
while (len-- != 0)
|
||||||
result = ((result << 1) | (result >> 31)) + reader.ReadUInt32();
|
result = ((result << 1) | (result >> 31)) + ms.ReadUInt32();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case PackageHashType.CRC32:
|
case PackageHashType.CRC32:
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user