Skip to content

Commit

Permalink
Make sure to ignore setDeviceControllerDelegate calls on non-running …
Browse files Browse the repository at this point in the history
…controllers. (#22778)

Otherwise we can end up with null-derefs trying to touch members that
no longer exist.

Fixes #22776
  • Loading branch information
bzbarsky-apple authored Sep 23, 2022
1 parent 1e3c5fe commit 46b4649
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,11 @@ - (void)removeDevice:(MTRDevice *)device

- (void)setDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate queue:(dispatch_queue_t)queue
{
VerifyOrReturn([self checkIsRunning]);

dispatch_async(_chipWorkQueue, ^{
VerifyOrReturn([self checkIsRunning]);

self->_deviceControllerDelegateBridge->setDelegate(self, delegate, queue);
});
}
Expand Down

0 comments on commit 46b4649

Please sign in to comment.