Skip to content

Commit

Permalink
Add subscribe null check
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Apr 13, 2023
1 parent dd40779 commit 994c73e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/darwin/Framework/CHIP/MTRBaseDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,14 @@ - (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullabl
if (attributes != nil) {
container.pathParams = static_cast<AttributePathParams *>(
Platform::MemoryCalloc([attributes count], sizeof(AttributePathParams)));
if (container.pathParams == nullptr) {
if (reportHandler) {
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
}
return;
}
for (MTRAttributeRequestPath * attribute in attributes) {
[attribute convertToAttributePathParams:container.pathParams[attributePathSize++]];
}
Expand All @@ -1403,6 +1411,14 @@ - (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullabl
if (events != nil) {
container.eventPathParams
= static_cast<EventPathParams *>(Platform::MemoryCalloc([events count], sizeof(EventPathParams)));
if (container.eventPathParams == nullptr) {
if (reportHandler) {
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
}
return;
}
for (MTREventRequestPath * event in events) {
[event convertToEventPathParams:container.eventPathParams[eventPathSize++]];
}
Expand Down

0 comments on commit 994c73e

Please sign in to comment.