File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1300,13 +1300,15 @@ private CharSequence generateArrayProperty(
13001300 indent + " #if __cplusplus >= 201703L\n " +
13011301 indent + " %1$s &put%2$s(std::string_view str) SBE_NOEXCEPT\n " +
13021302 indent + " {\n " +
1303- indent + " std::memcpy(m_buffer + m_offset + %3$d, str.c_str(), %4$d);\n " +
1303+ indent + " size_t length = str.length() < %4$d ? str.length() : %4$d;\n " +
1304+ indent + " std::memcpy(m_buffer + m_offset + %3$d, str.c_str(), length);\n " +
13041305 indent + " return *this;\n " +
13051306 indent + " }\n " +
13061307 indent + " #else\n " +
13071308 indent + " %1$s &put%2$s(const std::string& str) SBE_NOEXCEPT\n " +
13081309 indent + " {\n " +
1309- indent + " std::memcpy(m_buffer + m_offset + %3$d, str.c_str(), %4$d);\n " +
1310+ indent + " size_t length = str.length() < %4$d ? str.length() : %4$d;\n " +
1311+ indent + " std::memcpy(m_buffer + m_offset + %3$d, str.c_str(), length);\n " +
13101312 indent + " return *this;\n " +
13111313 indent + " }\n " +
13121314 indent + " #endif\n " ,
You can’t perform that action at this time.
0 commit comments