From 484c7bc63baab39904a1a715d199f879fd7a067a Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 30 Dec 2023 21:15:51 -0500 Subject: tcp lib refactor, hardware accelerated memcopy, service stack features --- lib/Utils/src/Extensions/MemoryExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/Utils/src/Extensions') 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 AsSpan(this IMemoryHandle 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); } -- cgit