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