From 76ca01a42076863e9909eb215ceca4a88ef09ac6 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Wed, 18 Mar 2015 18:12:45 +0100 Subject: [PATCH] Minor null reference fix --- Server/Core/Helper/UPnP.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Server/Core/Helper/UPnP.cs b/Server/Core/Helper/UPnP.cs index 079f93c0..aa65dde9 100644 --- a/Server/Core/Helper/UPnP.cs +++ b/Server/Core/Helper/UPnP.cs @@ -30,7 +30,10 @@ public static void ForwardPort(ushort port) finally { // Placed in here to make sure that a failed TcpClient will never linger! - c.Close(); + if (c != null) + { + c.Close(); + } } if (endPoint != null) @@ -48,8 +51,9 @@ public static void ForwardPort(ushort port) } } while (retry < 5); - // As by the original UPnP, if we can't successfully connect (above), - // shouldn't we just "return;"? + if (string.IsNullOrEmpty(ipAddr)) // If we can't successfully connect + return; + try { IStaticPortMappingCollection portMap = new UPnPNAT().StaticPortMappingCollection;