mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 23:35:59 +08:00
Use memcpy instead of strncpy in GCodeFormatter::emit_string() to silence the warning.
The warning was there because std::string_view::data() returns a pointer to a buffer that is not necessarily null-terminated. So, strncpy shouldn't be used on non-null-terminated buffers, but we always relied only on the buffer length, so it couldn't cause any issues.
This commit is contained in:
parent
c7d31f980a
commit
2c671d8d6c
@ -200,7 +200,8 @@ public:
|
||||
}
|
||||
|
||||
void emit_string(const std::string_view s) {
|
||||
strncpy(ptr_err.ptr, s.data(), s.size());
|
||||
// Be aware that std::string_view::data() returns a pointer to a buffer that is not necessarily null-terminated.
|
||||
memcpy(ptr_err.ptr, s.data(), s.size());
|
||||
ptr_err.ptr += s.size();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user