From af4c41ef08e0ea7eb446b28658c664c776645232 Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Sat, 30 Jan 2021 08:46:29 -0500
Subject: [PATCH] UPnP: Race-proof the fix

---
 router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java b/router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java
index 69d95e4fa2..38fb6ed3ca 100644
--- a/router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java
+++ b/router/java/src/org/cybergarage/upnp/ssdp/HTTPUSocket.java
@@ -203,9 +203,10 @@ public class HTTPUSocket
 		}
 		catch (Exception e) {
 			// I2P prevent NPE android gitlab #1
-			if (ssdpUniSock != null) {
-				Debug.warning("addr = " +ssdpUniSock.getLocalAddress().getHostName());
-				Debug.warning("port = " + ssdpUniSock.getLocalPort());
+			DatagramSocket sock = ssdpUniSock;
+			if (sock != null) {
+				Debug.warning("addr = " + sock.getLocalAddress().getHostName());
+				Debug.warning("port = " + sock.getLocalPort());
 			}
 			Debug.warning(e);
 			return false;
-- 
GitLab