Merge branch '2330-catch-npe-from-getbyinetaddress' into 'master'

Catch NPE from NetworkInterface.getByInetAddress()

Closes #2330

See merge request briar/briar!1809
This commit is contained in:
Torsten Grote
2023-09-06 11:16:09 +00:00

View File

@@ -201,6 +201,7 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
@Nullable
private InetAddress getIpv6AddressForInterface(InetAddress ipv4) {
try {
// We may get an NPE from getByInetAddress() on Android 11
NetworkInterface iface = NetworkInterface.getByInetAddress(ipv4);
if (iface == null) return null;
for (InetAddress addr : list(iface.getInetAddresses())) {
@@ -208,7 +209,7 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
}
// No suitable address
return null;
} catch (SocketException e) {
} catch (SocketException | NullPointerException e) {
logException(LOG, WARNING, e);
return null;
}