diff --git a/Realm/RLMSyncSessionRefreshHandle.mm b/Realm/RLMSyncSessionRefreshHandle.mm index 9032c18f27..dae423ea3b 100644 --- a/Realm/RLMSyncSessionRefreshHandle.mm +++ b/Realm/RLMSyncSessionRefreshHandle.mm @@ -248,8 +248,9 @@ - (void)_timerFired:(__unused NSTimer *)timer { kRLMSyncAppIDKey: [RLMSyncManager sharedManager].appID, }; + __weak RLMSyncSessionRefreshHandle *weakSelf = self; RLMSyncCompletionBlock handler = ^(NSError *error, NSDictionary *json) { - [self _onRefreshCompletionWithError:error json:json]; + [weakSelf _onRefreshCompletionWithError:error json:json]; }; [RLMNetworkClient postRequestToEndpoint:RLMServerEndpointAuth server:user.authenticationServer diff --git a/Realm/RLMSyncUser.mm b/Realm/RLMSyncUser.mm index 492432e651..2214dc240e 100644 --- a/Realm/RLMSyncUser.mm +++ b/Realm/RLMSyncUser.mm @@ -72,6 +72,7 @@ + (RLMSyncUser *)currentUser { - (instancetype)initWithAuthServer:(nullable NSURL *)authServer { if (self = [super init]) { self.authenticationServer = authServer; + self.refreshHandles = [NSMutableDictionary dictionary]; return self; } return nil;