From 92966a5c570a60f1c9c330c9f2bf0ae57481d12d Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Sat, 18 Jul 2015 00:52:44 +0200 Subject: [PATCH] Null-pointer check for SIP address types (fixes #506) --- .../davdroid/resource/LocalAddressBook.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java index 65e28911..c9318a4c 100644 --- a/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java +++ b/app/src/main/java/at/bitfire/davdroid/resource/LocalAddressBook.java @@ -635,18 +635,19 @@ public class LocalAddressBook extends LocalCollection { protected void populateSipAddress(Contact c, ContentValues row) { try { Impp impp = new Impp("sip:" + row.getAsString(SipAddress.SIP_ADDRESS)); - switch (row.getAsInteger(SipAddress.TYPE)) { - case SipAddress.TYPE_HOME: - impp.addType(ImppType.HOME); - break; - case SipAddress.TYPE_WORK: - impp.addType(ImppType.WORK); - break; - case SipAddress.TYPE_CUSTOM: - String customType = row.getAsString(SipAddress.LABEL); - if (StringUtils.isNotEmpty(customType)) - impp.addType(ImppType.get(labelToXName(customType))); - } + if (row.containsKey(SipAddress.TYPE)) + switch (row.getAsInteger(SipAddress.TYPE)) { + case SipAddress.TYPE_HOME: + impp.addType(ImppType.HOME); + break; + case SipAddress.TYPE_WORK: + impp.addType(ImppType.WORK); + break; + case SipAddress.TYPE_CUSTOM: + String customType = row.getAsString(SipAddress.LABEL); + if (StringUtils.isNotEmpty(customType)) + impp.addType(ImppType.get(labelToXName(customType))); + } c.getImpps().add(impp); } catch(IllegalArgumentException e) { Log.e(TAG, "Illegal SIP URI", e);