diff --git a/include/highfive/bits/H5Inspector_misc.hpp b/include/highfive/bits/H5Inspector_misc.hpp index 54bac1b0d..1613f87c3 100644 --- a/include/highfive/bits/H5Inspector_misc.hpp +++ b/include/highfive/bits/H5Inspector_misc.hpp @@ -385,19 +385,21 @@ struct inspector> { } static hdf5_type* data(type& val) { - return inspector::data(val[0]); + return val.empty() ? nullptr : inspector::data(val[0]); } static const hdf5_type* data(const type& val) { - return inspector::data(val[0]); + return val.empty() ? nullptr : inspector::data(val[0]); } template static void serialize(const type& val, It m) { - size_t subsize = inspector::getSizeVal(val[0]); - for (auto&& e: val) { - inspector::serialize(e, m); - m += subsize; + if (!val.empty()) { + size_t subsize = inspector::getSizeVal(val[0]); + for (auto&& e: val) { + inspector::serialize(e, m); + m += subsize; + } } }