Fixed StorageStream and NxFileStream from possibly reading too much

This commit is contained in:
Alex Barney 2019-02-22 20:19:53 -06:00
parent 5e321b7601
commit b5bd5346d4
2 changed files with 2 additions and 2 deletions

View file

@ -18,7 +18,7 @@ namespace LibHac.IO
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
{ {
int toRead = (int)Math.Min(count, Length - Position); int toRead = (int)Math.Min(count, Length - Position);
BaseFile.Read(buffer.AsSpan(offset, count), Position); BaseFile.Read(buffer.AsSpan(offset, toRead), Position);
Position += toRead; Position += toRead;
return toRead; return toRead;

View file

@ -21,7 +21,7 @@ namespace LibHac.IO
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
{ {
int toRead = (int) Math.Min(count, Length - Position); int toRead = (int) Math.Min(count, Length - Position);
BaseStorage.Read(buffer.AsSpan(offset, count), Position); BaseStorage.Read(buffer.AsSpan(offset, toRead), Position);
Position += toRead; Position += toRead;
return toRead; return toRead;