From ceced5af4cd11a3447d7247a6e503a4b92af178c Mon Sep 17 00:00:00 2001 From: Jesus Perez Date: Thu, 12 Dec 2024 08:09:35 +0100 Subject: [PATCH] Fix mutable size-three optional serialization Signed-off-by: Jesus Perez --- include/fastcdr/CdrSizeCalculator.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fastcdr/CdrSizeCalculator.hpp b/include/fastcdr/CdrSizeCalculator.hpp index 7f3a2328..9b1caea5 100644 --- a/include/fastcdr/CdrSizeCalculator.hpp +++ b/include/fastcdr/CdrSizeCalculator.hpp @@ -1245,12 +1245,14 @@ class CdrSizeCalculator if (CdrVersion::XCDRv2 == cdr_version_ && EncodingAlgorithmFlag::PL_CDR2 == current_encoding_ && 0 < calculated_size) { - if (8 < calculated_size) + if (8 < calculated_size || + (1 != calculated_size && 2 != calculated_size && 4 != calculated_size && + 8 != calculated_size)) { extra_size = 8; // Long EMHEADER. if (NO_SERIALIZED_MEMBER_SIZE != serialized_member_size_) { - extra_size -= 4; // Join NEXTINT and DHEADER. + calculated_size -= 4; // Join NEXTINT and DHEADER. } } else