Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Darwin] Fix a crash when a nil device is passed to a cluster on init #6276

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/chip-tool/gen/CHIPClustersObjc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,10 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin
return nil;
}

if (device == nullptr) {
return nil;
}

CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
if (err != CHIP_NO_ERROR) {
return nil;
Expand Down
5 changes: 5 additions & 0 deletions src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ private:
return nil;
}

if (device == nullptr)
{
return nil;
}

CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
if (err != CHIP_NO_ERROR) {
return nil;
Expand Down
4 changes: 4 additions & 0 deletions src/controller/python/gen/CHIPClustersObjc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,10 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin
return nil;
}

if (device == nullptr) {
return nil;
}

CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
if (err != CHIP_NO_ERROR) {
return nil;
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)stopDevicePairing:(uint64_t)deviceID error:(NSError * __autoreleasing *)error;
- (void)updateDevice:(uint64_t)deviceID fabricId:(uint64_t)fabricId;

- (CHIPDevice *)getPairedDevice:(uint64_t)deviceID error:(NSError * __autoreleasing *)error;
- (nullable CHIPDevice *)getPairedDevice:(uint64_t)deviceID error:(NSError * __autoreleasing *)error;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,10 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin
return nil;
}

if (device == nullptr) {
return nil;
}

CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
if (err != CHIP_NO_ERROR) {
return nil;
Expand Down