Skip to content

Commit

Permalink
Add null-terminated character when converting a string to a vector<ch…
Browse files Browse the repository at this point in the history
…ar>.
  • Loading branch information
s-trinh committed May 6, 2024
1 parent 5b2f4b8 commit 8aed5b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/core/test/tools/io/testNPZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ TEST_CASE("Test visp::cnpy::npy_load/npz_save", "[visp::cnpy I/O]")
{
const std::string save_string = "Open Source Visual Servoing Platform";
std::vector<char> vec_save_string(save_string.begin(), save_string.end());
// Manually add a null-terminated character
// https://stackoverflow.com/a/8247804
vec_save_string.push_back('\0');
const std::string identifier = "String";
visp::cnpy::npz_save(npz_filename, identifier, &vec_save_string[0], { vec_save_string.size() }, "w");

Expand Down

0 comments on commit 8aed5b8

Please sign in to comment.