aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils/src/Extensions
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-12-30 21:15:51 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-12-30 21:15:51 -0500
commit484c7bc63baab39904a1a715d199f879fd7a067a (patch)
tree949383bee253c5094536468be298c1ab1c03f7bf /lib/Utils/src/Extensions
parenta241620dd73f97496855284cf1fb1503debd28ab (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.cs8
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);
}