Added safeguard against reading past end-of-stream, as per method contract

This commit is contained in:
Mikhail Yakshin 2016-08-08 17:03:20 +03:00
parent 0fe8997f1e
commit d0e68f7708
1 changed files with 4 additions and 1 deletions

View File

@ -86,7 +86,10 @@ namespace Kaitai
/// <returns></returns>
public byte[] ReadBytes(long count)
{
return base.ReadBytes((int)count);
var bytes = base.ReadBytes((int) count);
if (bytes.Length < count)
throw new EndOfStreamException("requested " + count + " bytes, but got only " + bytes.Length + " bytes");
return bytes;
}
/// <summary>