Use module copies in RCTBridge APIs
Summary: This array can be modified while it's being iterated, so we need to take a copy. I also found another crash and guarded against it. Reviewed By: fkgozali Differential Revision: D8955708 fbshipit-source-id: 76250bc5d451776e74505733c0f3c14e555fb576
This commit is contained in:
parent
ccdd450b12
commit
3d8b83927b
|
@ -246,7 +246,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
- (NSArray *)modulesConformingToProtocol:(Protocol *)protocol
|
||||
{
|
||||
NSMutableArray *modules = [NSMutableArray new];
|
||||
for (Class moduleClass in self.moduleClasses) {
|
||||
for (Class moduleClass in [self.moduleClasses copy]) {
|
||||
if ([moduleClass conformsToProtocol:protocol]) {
|
||||
id module = [self moduleForClass:moduleClass];
|
||||
if (module) {
|
||||
|
|
|
@ -544,8 +544,9 @@ struct RCTInstanceCallback : public InstanceCallback {
|
|||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||
@"-[RCTCxxBridge initModulesWithDispatchGroup:] autoexported moduleData", nil);
|
||||
|
||||
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray arrayWithCapacity:moduleClasses.count];
|
||||
for (Class moduleClass in moduleClasses) {
|
||||
NSArray *moduleClassesCopy = [moduleClasses copy];
|
||||
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray arrayWithCapacity:moduleClassesCopy.count];
|
||||
for (Class moduleClass in moduleClassesCopy) {
|
||||
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
||||
|
||||
// Check for module name collisions
|
||||
|
|
Loading…
Reference in New Issue