From fb6d1ddbdffa6c3f6241d5242e0611e662acc2a0 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Wed, 29 Jun 2016 10:57:53 +0300 Subject: [PATCH] [ios] Added osmUserName checks to prevent crashes. --- .../Login/MWMAuthorizationLoginViewController.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm index aa3f2c32c0..e13906f317 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm @@ -158,7 +158,9 @@ using namespace osm_auth_ios; - (void)logout { [Statistics logEvent:kStatEventName(kStatAuthorization, kStatLogout)]; - GetFramework().DropUserStats(OSMUserName().UTF8String); + NSString * osmUserName = OSMUserName(); + if (osmUserName.length > 0) + GetFramework().DropUserStats(osmUserName.UTF8String); AuthorizationStoreCredentials({}); [self.navigationController popViewControllerAnimated:YES]; } @@ -169,15 +171,17 @@ using namespace osm_auth_ios; __weak auto weakSelf = self; auto const policy = force ? editor::UserStatsLoader::UpdatePolicy::Force : editor::UserStatsLoader::UpdatePolicy::Lazy; - GetFramework().UpdateUserStats(OSMUserName().UTF8String, policy, ^ - { - [weakSelf updateUI]; - }); + NSString * osmUserName = OSMUserName(); + if (osmUserName.length > 0) + GetFramework().UpdateUserStats(osmUserName.UTF8String, policy, ^{ [weakSelf updateUI]; }); } - (void)updateUI { - editor::UserStats stats = GetFramework().GetUserStats(OSMUserName().UTF8String); + NSString * osmUserName = OSMUserName(); + if (osmUserName.length == 0) + return; + editor::UserStats stats = GetFramework().GetUserStats(osmUserName.UTF8String); if (!stats) return; int32_t changesCount;