Skip to content

Commit d6b098b

Browse files
Fix valid response check. (#36461)
We should not be comparing strings by pointer value.
1 parent f10e90f commit d6b098b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/darwin/Framework/CHIP/MTRDeviceDataValidation.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ BOOL MTRInvokeResponseIsWellFormed(NSArray<MTRDeviceResponseValueDictionary> * r
207207

208208
// Now we know data is a dictionary (in fact a data-value). The only thing
209209
// we promise about it is that it has type MTRStructureValueType.
210-
if (data[MTRTypeKey] != MTRStructureValueType) {
210+
if (![MTRStructureValueType isEqual:data[MTRTypeKey]]) {
211211
MTR_LOG_ERROR("Invoke response data is not of structure type: %@", data);
212212
return NO;
213213
}

src/darwin/Framework/CHIPTests/MTRDeviceTests.m

+13
Original file line numberDiff line numberDiff line change
@@ -5580,6 +5580,19 @@ - (void)test044_InvokeResponseWellFormedness
55805580
],
55815581
@"valid" : @(YES),
55825582
},
5583+
@{
5584+
@"input" : @[
5585+
@{
5586+
@"commandPath" : [MTRCommandPath commandPathWithEndpointID:@(0) clusterID:@(6) commandID:@(0)],
5587+
@"data" : @ {
5588+
@"type" : @"Structure",
5589+
@"value" : @[], // Empty structure, valid
5590+
},
5591+
},
5592+
],
5593+
// Same as the previous test, but not using the SDK string constants
5594+
@"valid" : @(YES),
5595+
},
55835596
@{
55845597
@"input" : @[
55855598
@{

0 commit comments

Comments
 (0)