From d9ed4efc49c2e36f0dcd057f165a477e82268d5f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 28 Oct 2023 17:26:50 -0400 Subject: [PATCH] Correct openPMD_Attributable_attributes --- src/binding/c/backend/Attributable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/binding/c/backend/Attributable.cpp b/src/binding/c/backend/Attributable.cpp index 3b47740b07..32d8eeadd9 100644 --- a/src/binding/c/backend/Attributable.cpp +++ b/src/binding/c/backend/Attributable.cpp @@ -152,9 +152,10 @@ char **openPMD_Attributable_attributes(const openPMD_Attributable *attributable) const auto cxx_attributes = cxx_attributable->attributes(); const std::size_t num_attributes = cxx_attributes.size(); char **const attributes = - (char **)malloc(num_attributes * sizeof *attributes); + (char **)malloc((num_attributes + 1) * sizeof *attributes); for (std::size_t n = 0; n < num_attributes; ++n) attributes[n] = strdup(cxx_attributes[n].c_str()); + attributes[num_attributes] = nullptr; return attributes; }