Skip to content

Commit

Permalink
Fix project-chip#26115: Setup discriminator parameter corruption
Browse files Browse the repository at this point in the history
The setup discriminator parameter is being passed by reference, but
by the time the block is run by dispatch, that reference points to
stack contents that have been changed.  Making a local copy of the
discriminator fixes the problem.
  • Loading branch information
rob-the-dude committed Apr 16, 2023
1 parent 2e4064e commit d67b601
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platform/Darwin/BleConnectionDelegateImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ - (BOOL)isConnecting;
dispatch_queue_t bleWorkQueue;

void BleConnectionDelegateImpl::NewConnection(
Ble::BleLayer * bleLayer, void * appState, const SetupDiscriminator & deviceDiscriminator)
Ble::BleLayer * bleLayer, void * appState, const SetupDiscriminator & inDeviceDiscriminator)
{
assertChipStackLockedByCurrentThread();

SetupDiscriminator deviceDiscriminator = inDeviceDiscriminator;

ChipLogProgress(Ble, "%s", __FUNCTION__);
if (!bleWorkQueue) {
bleWorkQueue = dispatch_queue_create(kBleWorkQueueName, DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
Expand Down

0 comments on commit d67b601

Please sign in to comment.