Skip to content

Commit 2237ea6

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Fixed crash in RCTGenericDelegateSplitter (collection was mutated while being enumerated)
Summary: The concept of the class cannot guarantee that the set of delegates cannot be removed as a side-effect of calling a delegate, so we must make a copy of the delegates before calling on them. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D19213549 fbshipit-source-id: 7040b2994433d83e3148ec73820e051729be9e29
1 parent a09ab53 commit 2237ea6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

React/Fabric/Utils/RCTGenericDelegateSplitter.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,17 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
7878

7979
- (void)forwardInvocation:(NSInvocation *)invocation
8080
{
81+
NSMutableArray *targets = [[NSMutableArray alloc] initWithCapacity:_delegates.count];
82+
8183
for (id delegate in _delegates) {
8284
if ([delegate respondsToSelector:[invocation selector]]) {
83-
[invocation invokeWithTarget:delegate];
85+
[targets addObject:delegate];
8486
}
8587
}
88+
89+
for (id target in targets) {
90+
[invocation invokeWithTarget:target];
91+
}
8692
}
8793

8894
@end

0 commit comments

Comments
 (0)