hz/intrusive_ptr.h: strncpy() string terminators

When building the error message, ensure each strncpy()
includes the null byte terminating the copied string, even
though the first two will be immediately overwritten by
the next part. Silences compiler warnings.
This commit is contained in:
Frank Dana
2022-04-24 21:57:48 -04:00
committed by GitHub
parent 49b3d2b992
commit 9ca8ba43fa
+2 -2
View File
@@ -100,8 +100,8 @@ struct intrusive_ptr_error : virtual public std::exception { // from <exception
std::size_t tmsg_len = std::strlen(tmsg);
std::size_t tname_len = std::strlen(tname);
msg_ = new char[msg_len + tmsg_len + tname_len + 1];
std::strncpy(msg_, msg, msg_len);
std::strncpy(msg_ + msg_len, tmsg, tmsg_len);
std::strncpy(msg_, msg, msg_len + 1);
std::strncpy(msg_ + msg_len, tmsg, tmsg_len + 1);
std::strncpy(msg_ + msg_len + tmsg_len, tname, tname_len + 1);
}
#endif