From 80695728e800718a867a207fca9115275a2d4e66 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 25 Jan 2022 16:49:31 -0800 Subject: [PATCH] Fix reading attribute activeLocale failure (#14255) * Fix reading attribute activeLocale failure * Update src/app/clusters/localization-configuration-server/localization-configuration-server.cpp Co-authored-by: Boris Zbarsky Co-authored-by: Boris Zbarsky --- .../localization-configuration-server.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp index 86fe44249614f6..257676cea7d6bc 100644 --- a/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp +++ b/src/app/clusters/localization-configuration-server/localization-configuration-server.cpp @@ -39,6 +39,8 @@ using namespace chip::app::Clusters::LocalizationConfiguration::Attributes; namespace { +constexpr size_t kMaxActiveLocaleLength = 35; + class LocalizationConfigurationAttrAccess : public AttributeAccessInterface { public: @@ -150,7 +152,9 @@ void emberAfLocalizationConfigurationClusterServerInitCallback(EndpointId endpoi { DeviceLayer::AttributeList supportedLocales; CharSpan validLocale; - MutableCharSpan activeLocale; + + char outBuffer[kMaxActiveLocaleLength]; + MutableCharSpan activeLocale(outBuffer); EmberAfStatus status = ActiveLocale::Get(endpoint, activeLocale); VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Failed to read ActiveLocale with error: 0x%02x", status));