Skip to content

Commit 342df7c

Browse files
set the last byte in allocated char array to zero.
1 parent 73ef7b8 commit 342df7c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

dpctl-capi/helper/include/dpctl_string_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cstring_from_string(const std::string &str)
5050
#else
5151
std::strncpy(cstr, str.c_str(), cstr_len);
5252
#endif
53+
cstr[cstr_len - 1] = '\0';
5354
} catch (std::bad_alloc const &ba) {
5455
// \todo log error
5556
std::cerr << ba.what() << '\n';

0 commit comments

Comments
 (0)