Skip to content

Commit

Permalink
Correct openPMD_Attributable_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Oct 28, 2023
1 parent 3326bb6 commit d9ed4ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/binding/c/backend/Attributable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d9ed4ef

Please sign in to comment.