Skip to content

Commit de43365

Browse files
committed
Fixed out of range reads.
1 parent 2641259 commit de43365

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Memory/Memory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public byte ReadByte(int offset)
6969
{
7070
Contract.Requires(offset >= 0);
7171

72-
if (Offset + offset > data.Length)
72+
if (Offset + offset >= data.Length)
7373
{
7474
return 0;
7575
}
@@ -133,6 +133,11 @@ public string ReadPrintableASCIIString(int offset, int length)
133133
length = data.Length - Offset - offset;
134134
}
135135

136+
if (length <= 0)
137+
{
138+
return string.Empty;
139+
}
140+
136141
var sb = new StringBuilder(length);
137142
for (var i = 0; i < length; ++i)
138143
{

0 commit comments

Comments
 (0)