@@ -1271,7 +1271,10 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
1271
1271
if (attribute_type) {
1272
1272
*attribute_type = ZCL_CHAR_STRING_ATTRIBUTE_TYPE;
1273
1273
}
1274
- size_t string_len = strnlen ((const char *)val->val .a .b , val->val .a .s );
1274
+ size_t string_len = 0 ;
1275
+ if (val->val .a .b ) {
1276
+ string_len = strnlen ((const char *)val->val .a .b , val->val .a .s );
1277
+ }
1275
1278
size_t data_size_len = val->val .a .t - val->val .a .s ;
1276
1279
if (string_len >= UINT8_MAX || data_size_len != 1 ) {
1277
1280
return ESP_ERR_INVALID_ARG;
@@ -1298,7 +1301,10 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
1298
1301
if (attribute_type) {
1299
1302
*attribute_type = ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE;
1300
1303
}
1301
- size_t string_len = strnlen ((const char *)val->val .a .b , val->val .a .s );
1304
+ size_t string_len = 0 ;
1305
+ if (val->val .a .b ) {
1306
+ string_len = strnlen ((const char *)val->val .a .b , val->val .a .s );
1307
+ }
1302
1308
size_t data_size_len = val->val .a .t - val->val .a .s ;
1303
1309
if (string_len >= UINT8_MAX || data_size_len != 2 ) {
1304
1310
return ESP_ERR_INVALID_ARG;
@@ -1926,11 +1932,15 @@ void val_print(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id,
1926
1932
ESP_LOGI (TAG, " ********** %c : Endpoint 0x%04" PRIX16 " 's Cluster 0x%08" PRIX32 " 's Attribute 0x%08" PRIX32 " is %" PRIu64 " **********" , action,
1927
1933
endpoint_id, cluster_id, attribute_id, val->val .u64 );
1928
1934
} else if (val->type == ESP_MATTER_VAL_TYPE_CHAR_STRING) {
1935
+ const char *b = val->val .a .b ? (const char *)val->val .a .b : " (empty)" ;
1936
+ uint16_t s = val->val .a .b ? s : strlen (" (empty)" );
1929
1937
ESP_LOGI (TAG, " ********** %c : Endpoint 0x%04" PRIX16 " 's Cluster 0x%08" PRIX32 " 's Attribute 0x%08" PRIX32 " is %.*s **********" , action,
1930
- endpoint_id, cluster_id, attribute_id, val-> val . a . s , val-> val . a . b );
1938
+ endpoint_id, cluster_id, attribute_id, s, b);
1931
1939
} else if (val->type == ESP_MATTER_VAL_TYPE_LONG_CHAR_STRING) {
1940
+ const char *b = val->val .a .b ? (const char *)val->val .a .b : " (empty)" ;
1941
+ uint16_t s = val->val .a .b ? s : strlen (" (empty)" );
1932
1942
ESP_LOGI (TAG, " ********** %c : Endpoint 0x%04" PRIX16 " 's Cluster 0x%08" PRIX32 " 's Attribute 0x%08" PRIX32 " is %.*s **********" , action,
1933
- endpoint_id, cluster_id, attribute_id, val-> val . a . s , val-> val . a . b );
1943
+ endpoint_id, cluster_id, attribute_id, s, b);
1934
1944
} else {
1935
1945
ESP_LOGI (TAG, " ********** %c : Endpoint 0x%04" PRIX16 " 's Cluster 0x%08" PRIX32 " 's Attribute 0x%08" PRIX32 " is <invalid type: %d> **********" , action,
1936
1946
endpoint_id, cluster_id, attribute_id, val->type );
0 commit comments