Minor null reference fix

This commit is contained in:
MaxXor 2015-03-18 18:12:45 +01:00
parent 1a13442c12
commit 76ca01a420
1 changed files with 7 additions and 3 deletions

View File

@ -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;