Skip to content

Commit

Permalink
Fix crash in RCTLegacyViewManagerInteropCoordinator
Browse files Browse the repository at this point in the history
Summary:
Like the task mentions `strongSelf->_eventInterceptors` was crashing, probably because the coordinator was cleaned up before this block ran.

Check to make sure self is still valid before attempting to access any instance variables.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25073812

fbshipit-source-id: cdf666f2ac028b5523097f15ff51fbae9f9ffbd8
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Nov 19, 2020
1 parent 19d4cc2 commit bea3495
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ - (instancetype)initWithComponentData:(RCTComponentData *)componentData bridge:(
__weak __typeof(self) weakSelf = self;
_componentData.eventInterceptor = ^(NSString *eventName, NSDictionary *event, NSNumber *reactTag) {
__typeof(self) strongSelf = weakSelf;
InterceptorBlock block = [strongSelf->_eventInterceptors objectForKey:reactTag];
if (block) {
block(std::string([RCTNormalizeInputEventName(eventName) UTF8String]), convertIdToFollyDynamic(event ?: @{}));
if (strongSelf) {
InterceptorBlock block = [strongSelf->_eventInterceptors objectForKey:reactTag];
if (block) {
block(std::string([RCTNormalizeInputEventName(eventName) UTF8String]), convertIdToFollyDynamic(event ?: @{}));
}
}
};
}
Expand Down

0 comments on commit bea3495

Please sign in to comment.