Remove OwnedFlagBit from TryGetOwnedMemory index
authorBen Adams <thundercat@illyriad.co.uk>
Wed, 21 Feb 2018 23:30:17 +0000 (23:30 +0000)
committerJan Kotas <jkotas@microsoft.com>
Thu, 22 Feb 2018 07:36:57 +0000 (23:36 -0800)
src/mscorlib/shared/System/Runtime/InteropServices/MemoryMarshal.cs

index 633f56d..7fabf1e 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Runtime.InteropServices
         }
 
         /// <summary>
-        /// Gets a <see cref="OwnedMemory{T}"/> from the underlying readOnlyMemory.
+        /// Gets an <see cref="OwnedMemory{T}"/> from the underlying readOnlyMemory.
         /// If unable to get the <typeparamref name="TOwner"/> type, returns false.
         /// </summary>
         /// <typeparam name="T">The element type of the <paramref name="readOnlyMemory" />.</typeparam>
@@ -57,7 +57,7 @@ namespace System.Runtime.InteropServices
         }
 
         /// <summary>
-        /// Gets a <see cref="OwnedMemory{T}"/> and <paramref name="index" />, <paramref name="length" /> from the underlying memory.
+        /// Gets an <see cref="OwnedMemory{T}"/> and <paramref name="index" />, <paramref name="length" /> from the underlying memory.
         /// If unable to get the <typeparamref name="TOwner"/> type, returns false.
         /// </summary>
         /// <typeparam name="T">The element type of the <paramref name="readOnlyMemory" />.</typeparam>
@@ -72,6 +72,7 @@ namespace System.Runtime.InteropServices
         {
             TOwner owner; // Use register for null comparison rather than byref
             ownedMemory = owner = readOnlyMemory.GetObjectStartLength(out index, out length) as TOwner;
+            index &= ReadOnlyMemory<T>.RemoveOwnedFlagBitMask;
             return !ReferenceEquals(owner, null);
         }