From 7cdd57cc5f3386287775d8e75b30e9237de9ef44 Mon Sep 17 00:00:00 2001 From: karutoh Date: Sat, 17 Feb 2024 00:52:03 -0800 Subject: [PATCH] Fixed Serializer::ReadStr. --- include/ehs/Serializer.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/ehs/Serializer.h b/include/ehs/Serializer.h index 594500a..78b6658 100644 --- a/include/ehs/Serializer.h +++ b/include/ehs/Serializer.h @@ -1071,7 +1071,9 @@ namespace ehs template Str ReadStr(O size = 0) { - if (!size) + bool sizeKnown = size; + + if (!sizeKnown) while (&data[offset + sizeof(T) * size]) size++; @@ -1096,7 +1098,10 @@ namespace ehs Util::Copy(&result[0], &data[offset], result.Size(true)); } - offset += result.Size(true) + 1; + offset += result.Size(true); + + if (!sizeKnown) + offset++; return result; }