diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 7836c0e7905c5d..eee83669ed5fa5 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -1011,23 +1011,25 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri AttributePathParams * attributePathParamsListToFree = attributePathParamsList.Get(); EventPathParams * eventPathParamsListToFree = eventPathParamsList.Get(); - auto onDone = [resultArray, interactionStatus, bridge, successCb, failureCb, attributePathParamsListToFree, - eventPathParamsListToFree](BufferedReadClientCallback * callback) { - if (*interactionStatus != CHIP_NO_ERROR) { - // Failure - failureCb(bridge, *interactionStatus); - } else { - // Success - successCb(bridge, resultArray); - } - if (attributePathParamsListToFree != nullptr) { - Platform::MemoryFree(attributePathParamsListToFree); - } - if (eventPathParamsListToFree != nullptr) { - Platform::MemoryFree(eventPathParamsListToFree); - } - chip::Platform::Delete(callback); - }; + auto onDone + = [resultArray, interactionStatus, bridge, successCb, failureCb, attributePathParamsListToFree, + eventPathParamsListToFree](BufferedReadClientCallback * callback) { + if (*interactionStatus != CHIP_NO_ERROR) { + // Failure + failureCb(bridge, *interactionStatus); + } else { + // Success + successCb(bridge, resultArray); + } + if (attributePathParamsListToFree != nullptr) { + Platform::MemoryFree(attributePathParamsListToFree); + } + if (eventPathParamsListToFree != nullptr) { + Platform::MemoryFree(eventPathParamsListToFree); + } + chip::Platform::Delete(callback); + }; + auto callback = chip::Platform::MakeUnique>( attributePathParamsList.Get(), readParams.mAttributePathParamsListSize, eventPathParamsList.Get(),