Skip to content

Commit

Permalink
CopyBuffer: Skip Zero Elements
Browse files Browse the repository at this point in the history
Avoid operating on invalid memory in `CopyBuffer` if the operation
is zero elements.
  • Loading branch information
ax3l committed Feb 3, 2023
1 parent 98bef0e commit 644306e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/adios2/helper/adiosMemory.inl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ void CopyToBuffer(std::vector<char> &buffer, size_t &position, const T *source,
const size_t elements) noexcept
{
const char *src = reinterpret_cast<const char *>(source);
std::copy(src, src + elements * sizeof(T), buffer.begin() + position);
if (elements > 0)
std::copy(src, src + elements * sizeof(T), buffer.begin() + position);
position += elements * sizeof(T);
}

Expand Down

0 comments on commit 644306e

Please sign in to comment.