data: Ensure that content block always exists, even content wasn't set explicitly
Before this commit, when setContent was never called on a Data packet,
the library was skipping Content part, which violates the packet format.
Change-Id: Ic175c384c16e828fa40836d952f4688fe3edc311
diff --git a/src/data.hpp b/src/data.hpp
index e2d9451..29a38d6 100644
--- a/src/data.hpp
+++ b/src/data.hpp
@@ -216,6 +216,9 @@
inline const Block&
Data::getContent() const
{
+ if (content_.empty())
+ content_ = dataBlock(Tlv::Content, reinterpret_cast<const uint8_t*>(0), 0);
+
if (!content_.hasWire())
content_.encode();
return content_;