diff --git a/changelog b/changelog index d67263829..0b5633a22 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-andr vNext ---------- +- [PATCH] Add null checks for guest account ids (#2361) Version 7.0.1 ---------- diff --git a/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java b/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java index 49d8a5d6d..80969d5ed 100644 --- a/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java +++ b/msal/src/main/java/com/microsoft/identity/client/AccountAdapter.java @@ -54,13 +54,23 @@ private static class GuestAccountFilter implements CacheRecordFilter { @Override public List filter(@NonNull List records) { + final String methodTag = TAG + ":GuestAccountFilter"; final List result = new ArrayList<>(); for (final ICacheRecord cacheRecord : records) { final String acctHomeAccountId = cacheRecord.getAccount().getHomeAccountId(); final String acctLocalAccountId = cacheRecord.getAccount().getLocalAccountId(); + boolean isValid = true; - if (!acctHomeAccountId.contains(acctLocalAccountId)) { + if (acctHomeAccountId == null) { + Logger.warn(methodTag, "Home account ID is null for entry."); + isValid = false; + } + if (acctLocalAccountId == null) { + Logger.warn(methodTag, "Local account ID is null for entry."); + isValid = false; + } + if (isValid && !acctHomeAccountId.contains(acctLocalAccountId)) { result.add(cacheRecord); } }