From 0664d6ac7b8d0cefac8fa92df625fe653d606b1a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 4 Dec 2015 15:35:22 +0100 Subject: avoid some NPEs --- src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 2 +- src/main/java/eu/siacs/conversations/utils/DNSHelper.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index f7a0e210..ab1319ef 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -365,7 +365,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa break; case Message.ENCRYPTION_AXOLOTL: AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); - if (axolotlService.trustedSessionVerified(conversation)) { + if (axolotlService != null && axolotlService.trustedSessionVerified(conversation)) { mEditMessage.setHint(getString(R.string.send_omemo_x509_message)); } else { mEditMessage.setHint(getString(R.string.send_omemo_message)); diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index f3c4f79a..e07df627 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -227,10 +227,11 @@ public class DNSHelper { } public static boolean isIp(final String server) { - return PATTERN_IPV4.matcher(server).matches() + return server != null && ( + PATTERN_IPV4.matcher(server).matches() || PATTERN_IPV6.matcher(server).matches() || PATTERN_IPV6_6HEX4DEC.matcher(server).matches() || PATTERN_IPV6_HEX4DECCOMPRESSED.matcher(server).matches() - || PATTERN_IPV6_HEXCOMPRESSED.matcher(server).matches(); + || PATTERN_IPV6_HEXCOMPRESSED.matcher(server).matches()); } } -- cgit v1.2.3