From 07711f01b3d0cc9c8c38e8628b5e1dc402081e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 6 Jun 2015 13:39:01 +0200 Subject: [PATCH] add exceptions for debugging --- OpenRA.Game/FileSystem/MixFile.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Game/FileSystem/MixFile.cs b/OpenRA.Game/FileSystem/MixFile.cs index 034ba7d1dd..cfc7634e3c 100644 --- a/OpenRA.Game/FileSystem/MixFile.cs +++ b/OpenRA.Game/FileSystem/MixFile.cs @@ -122,6 +122,15 @@ namespace OpenRA.FileSystem static uint[] ReadBlocks(Stream s, long offset, int count) { + if (offset < 0) + throw new ArgumentOutOfRangeException("offset", "Non-negative number required."); + + if (count < 0) + throw new ArgumentOutOfRangeException("count", "Non-negative number required."); + + if (offset + (count * 2) > s.Length) + throw new ArgumentException("Bytes to read {0} and offset {1} greater than stream length {2}.".F(count * 2, offset, s.Length)); + s.Seek(offset, SeekOrigin.Begin); // A block is a single encryption unit (represented as two 32-bit integers)