diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index d208a99d00bbad..c4f949b13d78e9 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1723,7 +1723,9 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio #endif if (status != CHIP_NO_ERROR) { - ChipLogError(Controller, "Unable to find country code, defaulting to XX"); + actualCountryCodeSize = 2; + memset(countryCodeStr, 'X', actualCountryCodeSize); + ChipLogError(Controller, "Unable to find country code, defaulting to %s", countryCodeStr); } chip::CharSpan countryCode(countryCodeStr, actualCountryCodeSize);