From cef817a10c0816e6222a5b27def2e87b081a3bf8 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Fri, 17 Jan 2020 10:41:38 -0800 Subject: [PATCH] pad as with 0s in case size is smaller than expected --- include/yaml-cpp/node/convert.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index 8fbcc4a..175ea89 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "yaml-cpp/binary.h" #include "yaml-cpp/node/impl.h" @@ -284,12 +285,15 @@ struct convert> { rhs[i] = node[i].as(); #endif } + for (auto i = node.size(); i < N; i++) { + std::memset(&rhs[i], 0, sizeof(T)); + } return true; } private: static bool isNodeValid(const Node& node) { - return node.IsSequence() && node.size() == N; + return node.IsSequence() && node.size() <= N; } };