diff --git a/BeefLibs/corlib/src/Array.bf b/BeefLibs/corlib/src/Array.bf index a6dc0e86..b4846ec3 100644 --- a/BeefLibs/corlib/src/Array.bf +++ b/BeefLibs/corlib/src/Array.bf @@ -270,16 +270,18 @@ namespace System public void CopyTo(Span destination) { - Debug.Assert(destination.Length >= mLength); + Debug.Assert(destination.[Friend]mPtr != null); + Debug.Assert(destination.[Friend]mLength >= mLength); + Internal.MemCpy(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T)); } public void CopyTo(Span destination, int srcOffset) { - Debug.Assert(destination.Length >= mLength); - Debug.Assert((uint)srcOffset <= (uint)mLength); + Debug.Assert(destination.[Friend]mPtr != null); + Debug.Assert((uint)destination.[Friend]mLength - (uint)srcOffset < (uint)mLength); - Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * (mLength - srcOffset), alignof(T)); + Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * (destination.Length - srcOffset), alignof(T)); } public Span.Enumerator GetEnumerator()