From 94e3346d45b90080c84ba8f418bbc6f6878cc9a4 Mon Sep 17 00:00:00 2001 From: ahsonkhan Date: Fri, 19 Jan 2018 20:22:11 -0800 Subject: [PATCH] Address PR feedback --- src/Common/tests/System/Buffers/NativeOwnedMemory.cs | 2 +- src/System.Memory/tests/Memory/CustomMemoryForTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/tests/System/Buffers/NativeOwnedMemory.cs b/src/Common/tests/System/Buffers/NativeOwnedMemory.cs index b734ee672d3f..f68a70e074f7 100644 --- a/src/Common/tests/System/Buffers/NativeOwnedMemory.cs +++ b/src/Common/tests/System/Buffers/NativeOwnedMemory.cs @@ -55,7 +55,7 @@ protected override bool IsRetained public override unsafe MemoryHandle Pin(int offset = 0) { - if (offset < 0 || (_length > 0 && offset >= _length)) throw new ArgumentOutOfRangeException(nameof(offset)); + if (offset < 0 || offset > _length) throw new ArgumentOutOfRangeException(nameof(offset)); void* pointer = (void*)((byte*)_ptr + offset); return new MemoryHandle(this, pointer); } diff --git a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs index 30ccfba556e6..c8180303ee62 100644 --- a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs +++ b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs @@ -44,7 +44,7 @@ public override MemoryHandle Pin(int offset = 0) unsafe { Retain(); - if (offset < 0 || (_array.Length > 0 && offset >= _array.Length)) throw new ArgumentOutOfRangeException(nameof(offset)); + if (offset < 0 || offset > _array.Length) throw new ArgumentOutOfRangeException(nameof(offset)); var handle = GCHandle.Alloc(_array, GCHandleType.Pinned); return new MemoryHandle(this, Unsafe.Add((void*)handle.AddrOfPinnedObject(), offset), handle); }