From bef14dc1ad23dc978f65bb6c2dc86c05c69c15d0 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Jan 2017 16:20:20 +0900 Subject: [PATCH] [Fix] Add a null check --- websocket-sharp/Server/WebSocketServer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index bcf43346..1ebffe3b 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -176,9 +176,17 @@ namespace WebSocketSharp.Server throw new ArgumentException (msg, "url"); var host = uri.DnsSafeHost; + var addr = host.ToIPAddress (); - if (!addr.IsLocal ()) - throw new ArgumentException ("The host part isn't a local host name: " + url, "url"); + if (addr == null) { + msg = "It could not be converted to an IP address."; + throw new ArgumentException (msg, "url"); + } + + if (!addr.IsLocal ()) { + msg = "The IP address is not a local IP address."; + throw new ArgumentException (msg, "url"); + } init (host, addr, uri.Port, uri.Scheme == "wss"); }