diff options
Diffstat (limited to 'src/zenutil')
| -rw-r--r-- | src/zenutil/packageformat.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/zenutil/packageformat.cpp b/src/zenutil/packageformat.cpp index 2512351f5..963a442cd 100644 --- a/src/zenutil/packageformat.cpp +++ b/src/zenutil/packageformat.cpp @@ -51,6 +51,7 @@ FormatPackageMessageBuffer(const CbPackage& Data, FormatFlags Flags, void* Targe for (IoBuffer& Buf : Message) { + ZEN_ASSERT(Buf.GetSize() > 0); Buffers.push_back(SharedBuffer(Buf)); } @@ -200,6 +201,7 @@ FormatPackageMessage(const CbPackage& Data, FormatFlags Flags, void* TargetProce // Root object IoBuffer RootIoBuffer = Data.GetObject().GetBuffer().AsIoBuffer(); + ZEN_ASSERT(RootIoBuffer.GetSize() > 0); ResponseBuffers.push_back(RootIoBuffer); // Root object *AttachmentInfo++ = {.PayloadSize = RootIoBuffer.Size(), .Flags = CbAttachmentEntry::kIsObject, .AttachmentHash = Data.GetObjectHash()}; @@ -257,6 +259,7 @@ FormatPackageMessage(const CbPackage& Data, FormatFlags Flags, void* TargetProce for (const SharedBuffer& Segment : Compressed.GetSegments()) { + ZEN_ASSERT(Segment.GetSize() > 0); ResponseBuffers.push_back(Segment.AsIoBuffer()); } } @@ -264,6 +267,7 @@ FormatPackageMessage(const CbPackage& Data, FormatFlags Flags, void* TargetProce else if (CbObject AttachmentObject = Attachment.AsObject()) { IoBuffer ObjIoBuffer = AttachmentObject.GetBuffer().AsIoBuffer(); + ZEN_ASSERT(ObjIoBuffer.GetSize() > 0); ResponseBuffers.push_back(ObjIoBuffer); *AttachmentInfo++ = {.PayloadSize = ObjIoBuffer.Size(), @@ -307,6 +311,7 @@ FormatPackageMessage(const CbPackage& Data, FormatFlags Flags, void* TargetProce for (const SharedBuffer& Segment : AttachmentBinary.GetSegments()) { + ZEN_ASSERT(Segment.GetSize() > 0); ResponseBuffers.push_back(Segment.AsIoBuffer()); } } @@ -808,6 +813,13 @@ TEST_CASE("CbPackage.Serialization") Reader.Finalize(); } +TEST_CASE("CbPackage.EmptyObject") +{ + CbPackage Pkg; + Pkg.SetObject({}); + std::vector<IoBuffer> Result = FormatPackageMessage(Pkg, nullptr); +} + TEST_CASE("CbPackage.LocalRef") { ScopedTemporaryDirectory TempDir; |