Skip to content

Commit

Permalink
Make sure device map is accessed safely with lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jtung-apple committed Feb 19, 2025
1 parent 4782a4f commit 9d59496
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ @implementation MTRDeviceController_XPC
- (void)_updateRegistrationInfo
{
dispatch_async(self.workQueue, ^{
std::lock_guard lock(*self.deviceMapLock);

NSMutableDictionary * registrationInfo = [NSMutableDictionary dictionary];

NSMutableDictionary * controllerContext = [NSMutableDictionary dictionary];
NSMutableArray * nodeIDs = [NSMutableArray array];

for (NSNumber * nodeID in [self.nodeIDToDeviceMap keyEnumerator]) {
MTRDevice * device = [self _deviceForNodeID:nodeID createIfNeeded:NO];
MTRDevice * device = self.nodeIDToDeviceMap[nodeID];
if ([device delegateExists]) {
NSMutableDictionary * nodeDictionary = [NSMutableDictionary dictionary];
MTR_REQUIRED_ATTRIBUTE(MTRDeviceControllerRegistrationNodeIDKey, nodeID, nodeDictionary)
Expand Down

0 comments on commit 9d59496

Please sign in to comment.