diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index 1598567e212880..4c3e05051a9d4e 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -230,9 +230,9 @@ CHIP_ERROR ConvertReportTlvToJson(const uint32_t id, TLV::TLVReader & data, std: { TLV::TLVWriter writer; TLV::TLVReader readerForJavaTLV; - uint32_t size = 0; - size_t bufferLen = readerForJavaTLV.GetTotalLength() + EXTRA_SPACE_FOR_ATTRIBUTE_TAG; + uint32_t size = 0; readerForJavaTLV.Init(data); + size_t bufferLen = readerForJavaTLV.GetTotalLength() + EXTRA_SPACE_FOR_ATTRIBUTE_TAG; std::unique_ptr buffer = std::unique_ptr(new uint8_t[bufferLen]); writer.Init(buffer.get(), bufferLen); TLV::TLVType outer;