aboutsummaryrefslogtreecommitdiff
path: root/zencore/compactbinary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/compactbinary.cpp')
-rw-r--r--zencore/compactbinary.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp
index 62c60418c..73ca9832f 100644
--- a/zencore/compactbinary.cpp
+++ b/zencore/compactbinary.cpp
@@ -2,6 +2,7 @@
#include "zencore/compactbinary.h"
+#include "zencore/compactbinaryvalidation.h"
#include <zencore/endian.h>
#include <zencore/stream.h>
#include <zencore/trace.h>
@@ -1072,7 +1073,10 @@ LoadCompactBinary(BinaryReader& Ar, BufferAllocator Allocator)
{
break;
}
- ZEN_ASSERT(FieldSize > 0, "Failed to load from invalid compact binary data.");
+ if (FieldSize == 0)
+ {
+ return CbField();
+ }
}
// Allocate the buffer, copy the header, and read the remainder of the field.
@@ -1085,6 +1089,10 @@ LoadCompactBinary(BinaryReader& Ar, BufferAllocator Allocator)
{
Ar.Read(View.GetData(), View.GetSize());
}
+ if (ValidateCompactBinary(Buffer, CbValidateMode::Default) != CbValidateError::None)
+ {
+ return CbField();
+ }
return CbField(SharedBuffer(std::move(Buffer)));
}