diff --git a/OpenRA.Game/FileFormats/VqaReader.cs b/OpenRA.Game/FileFormats/VqaReader.cs index 32fc066b63..ab7f9cb218 100644 --- a/OpenRA.Game/FileFormats/VqaReader.cs +++ b/OpenRA.Game/FileFormats/VqaReader.cs @@ -315,7 +315,7 @@ namespace OpenRA.FileFormats // Full frame-modifier case "CBFZ": var decodeMode = s.Peek() == 0; - s.Read(fileBuffer, 0, subchunkLength); + s.ReadBytes(fileBuffer, 0, subchunkLength); Array.Clear(cbf, 0, cbf.Length); Array.Clear(cbfBuffer, 0, cbfBuffer.Length); var decodeCount = 0; @@ -386,7 +386,7 @@ namespace OpenRA.FileFormats return; case "VPRZ": Array.Clear(origData, 0, origData.Length); - s.Read(fileBuffer, 0, subchunkLength); + s.ReadBytes(fileBuffer, 0, subchunkLength); if (fileBuffer[0] != 0) vtprSize = Format80.DecodeInto(fileBuffer, origData); else @@ -394,7 +394,7 @@ namespace OpenRA.FileFormats return; case "VPTR": Array.Clear(origData, 0, origData.Length); - s.Read(origData, 0, subchunkLength); + s.ReadBytes(origData, 0, subchunkLength); vtprSize = subchunkLength; return; default: diff --git a/OpenRA.Game/StreamExts.cs b/OpenRA.Game/StreamExts.cs index b525e67ed9..eb9699cc77 100755 --- a/OpenRA.Game/StreamExts.cs +++ b/OpenRA.Game/StreamExts.cs @@ -28,6 +28,8 @@ namespace OpenRA public static void ReadBytes(this Stream s, byte[] buffer, int offset, int count) { + if (count < 0) + throw new ArgumentOutOfRangeException("count", "Non-negative number required."); while (count > 0) { int bytesRead;