Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorahsonkhan <ahson_ahmedk@yahoo.com>2017-12-08 08:34:01 +0300
committerahsonkhan <ahson_ahmedk@yahoo.com>2017-12-08 08:34:01 +0300
commit21b48fdbb365ff64c337d9d1356a99ceb3e30da4 (patch)
tree7269096ac420ee683978610f33c04c8e2af9f18b /src/System.Memory/tests/Memory
parent9351823999e4cb4d3476951564a18c7359c7f8fd (diff)
Add bounds checks for offset in classes that impl OwnedMemory
Diffstat (limited to 'src/System.Memory/tests/Memory')
-rw-r--r--src/System.Memory/tests/Memory/CustomMemoryForTest.cs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs
index d663111bdb..618b18882e 100644
--- a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs
+++ b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs
@@ -39,13 +39,14 @@ namespace System.MemoryTests
}
}
- public override MemoryHandle Pin(int index = 0)
+ public override MemoryHandle Pin(int offset = 0)
{
unsafe
{
Retain();
+ if (offset < 0 || offset >= _array.Length) throw new ArgumentOutOfRangeException(nameof(offset));
var handle = GCHandle.Alloc(_array, GCHandleType.Pinned);
- return new MemoryHandle(this, Unsafe.Add<byte>((void*)handle.AddrOfPinnedObject(), index), handle);
+ return new MemoryHandle(this, Unsafe.Add<byte>((void*)handle.AddrOfPinnedObject(), offset), handle);
}
}