Added safeguard against reading past end-of-stream, as per method contract
This commit is contained in:
parent
0fe8997f1e
commit
d0e68f7708
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue