Sanity check
The theoretical chances of this happening are low. The compiler should complain that you're trying to put >int32.MaxValue in, but a check is totally fine.
This commit is contained in:
parent
9d0f6c385a
commit
73c830bde9
|
@ -55,6 +55,12 @@ namespace Kaitai
|
|||
///<summary>Read N bytes from the stream.</summary>
|
||||
public byte[] readBytes(int n)
|
||||
{
|
||||
|
||||
if (n > Int32.MaxValue)
|
||||
{
|
||||
throw new ArgumentException(String.Format("Cannot allocate {0} bytes", n));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
byte[] tmp = new byte[n];
|
||||
|
|
Loading…
Reference in New Issue