diff options
author | vnugent <public@vaughnnugent.com> | 2023-12-30 21:15:51 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-12-30 21:15:51 -0500 |
commit | 484c7bc63baab39904a1a715d199f879fd7a067a (patch) | |
tree | 949383bee253c5094536468be298c1ab1c03f7bf /lib/Utils/src/Extensions | |
parent | a241620dd73f97496855284cf1fb1503debd28ab (diff) |
tcp lib refactor, hardware accelerated memcopy, service stack features
Diffstat (limited to 'lib/Utils/src/Extensions')
-rw-r--r-- | lib/Utils/src/Extensions/MemoryExtensions.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Utils/src/Extensions/MemoryExtensions.cs b/lib/Utils/src/Extensions/MemoryExtensions.cs index 58d3d23..28969ea 100644 --- a/lib/Utils/src/Extensions/MemoryExtensions.cs +++ b/lib/Utils/src/Extensions/MemoryExtensions.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Utils @@ -823,8 +823,12 @@ namespace VNLib.Utils.Extensions public static Span<T> AsSpan<T>(this IMemoryHandle<T> handle, nint start) { _ = handle ?? throw new ArgumentNullException(nameof(handle)); + if(start < 0 || (uint)start > handle.Length) + { + throw new ArgumentOutOfRangeException(nameof(start)); + } //calculate a remaining count - int count = (int)(handle.Length - (nuint)start); + int count = checked((int)(handle.Length - (uint)start)); //call the other overload return AsSpan(handle, start, count); } |