From d74e5030e2cdfdeae2b4063adbdb5d5364dd08cf Mon Sep 17 00:00:00 2001 From: MrSmoke <709976+MrSmoke@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:24:51 +1100 Subject: [PATCH] add null check --- .../Primitives/src/Extensions/IpAddressExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Primitives/Primitives/src/Extensions/IpAddressExtensions.cs b/src/Primitives/Primitives/src/Extensions/IpAddressExtensions.cs index 0b208ad..e7e7581 100644 --- a/src/Primitives/Primitives/src/Extensions/IpAddressExtensions.cs +++ b/src/Primitives/Primitives/src/Extensions/IpAddressExtensions.cs @@ -19,6 +19,9 @@ public static class IpAddressExtensions /// bool isPrivate = IPAddress.Parse("127.0.0.1").IsPrivate(); public static bool IsPrivate(this IPAddress ip) { + if (ip is null) + throw new ArgumentNullException(nameof(ip)); + // Map back to IPv4 if mapped to IPv6, for example "::ffff:1.2.3.4" to "1.2.3.4". if (ip.IsIPv4MappedToIPv6) ip = ip.MapToIPv4();