@@ -292,13 +292,8 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
292
292
}
293
293
}
294
294
295
- for (uint8_t i = 0 ; ep && ( i < ep->clusterCount ) ; i++)
295
+ for (uint8_t i = 0 ; i < ep->clusterCount ; i++)
296
296
{
297
- if (!ep->cluster )
298
- {
299
- continue ;
300
- }
301
-
302
297
const EmberAfCluster * cluster = &(ep->cluster [i]);
303
298
if (!cluster->attributes )
304
299
{
@@ -308,11 +303,14 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
308
303
for (uint16_t j = 0 ; j < cluster->attributeCount ; j++)
309
304
{
310
305
const EmberAfAttributeMetadata * attr = &(cluster->attributes [j]);
311
- if (emberAfAttributeSize (attr) > chip::app::Compatibility::Internal::gEmberAttributeIOBufferSpan .size ())
306
+ uint16_t attrSize = emberAfAttributeSize (attr);
307
+ size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan .size ();
308
+ if (attrSize > bufferSize)
312
309
{
313
310
ChipLogError (DataManagement,
314
- " Attribute %u (id=" ChipLogFormatMEI " ) of Cluster %u (id=" ChipLogFormatMEI " ) too large" , j,
315
- ChipLogValueMEI (attr->attributeId ), i, ChipLogValueMEI (cluster->clusterId ));
311
+ " Attribute size %u exceeds max size %zu, (attrId=" ChipLogFormatMEI " , clusterId=" ChipLogFormatMEI
312
+ " )" ,
313
+ attrSize, bufferSize, ChipLogValueMEI (attr->attributeId ), ChipLogValueMEI (cluster->clusterId ));
316
314
return CHIP_ERROR_NO_MEMORY;
317
315
}
318
316
}
0 commit comments