From 29e7777d4a3a521b3f5db3ee48d47ecade71eaa7 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 11 Jun 2024 14:15:30 +0530 Subject: [PATCH] components/esp_matter: Fix size of string to print the value of char string attribute --- components/esp_matter/esp_matter_attribute_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_matter/esp_matter_attribute_utils.cpp b/components/esp_matter/esp_matter_attribute_utils.cpp index a36226ad4..91fc70c3c 100644 --- a/components/esp_matter/esp_matter_attribute_utils.cpp +++ b/components/esp_matter/esp_matter_attribute_utils.cpp @@ -1933,12 +1933,12 @@ void val_print(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, endpoint_id, cluster_id, attribute_id, val->val.u64); } else if (val->type == ESP_MATTER_VAL_TYPE_CHAR_STRING) { const char *b = val->val.a.b ? (const char *)val->val.a.b : "(empty)"; - uint16_t s = val->val.a.b ? s : strlen("(empty)"); + uint16_t s = val->val.a.b ? val->val.a.s : strlen("(empty)"); ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %.*s **********", action, endpoint_id, cluster_id, attribute_id, s, b); } else if (val->type == ESP_MATTER_VAL_TYPE_LONG_CHAR_STRING) { const char *b = val->val.a.b ? (const char *)val->val.a.b : "(empty)"; - uint16_t s = val->val.a.b ? s : strlen("(empty)"); + uint16_t s = val->val.a.b ? val->val.a.s : strlen("(empty)"); ESP_LOGI(TAG, "********** %c : Endpoint 0x%04" PRIX16 "'s Cluster 0x%08" PRIX32 "'s Attribute 0x%08" PRIX32 " is %.*s **********", action, endpoint_id, cluster_id, attribute_id, s, b); } else {