Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nil check for crash #3799

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ - (void)completeWithSuccess {
if (self.completionBlock) {
dispatch_async(dispatch_get_main_queue(), ^{
SFUserAccount *account = [[SFUserAccountManager sharedInstance] accountForCredentials:self.credentials];
NSDictionary *userInfo = @{ kSFNotificationUserInfoAccountKey : account };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a crash reported at this line with reason -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0] but we don’t have app logs or repro steps. It looks like the crash would be because the account is nil so I added a check for that for now but I’d like to dig deeper into why the account is nil if we get any more info

NSMutableDictionary *userInfo = [NSMutableDictionary new];
if (account) {
[userInfo setValue:account forKey:kSFNotificationUserInfoAccountKey];
} else {
[SFSDKCoreLogger e:[self class] format:@"%@ No account for credentials", NSStringFromSelector(_cmd)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:kSFNotificationUserDidRefreshToken
object:self
userInfo:userInfo];
Expand Down
Loading