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(
1300
1300
indent + " #if __cplusplus >= 201703L\n " +
1301
1301
indent + " %1$s &put%2$s(std::string_view str) SBE_NOEXCEPT\n " +
1302
1302
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 " +
1304
1305
indent + " return *this;\n " +
1305
1306
indent + " }\n " +
1306
1307
indent + " #else\n " +
1307
1308
indent + " %1$s &put%2$s(const std::string& str) SBE_NOEXCEPT\n " +
1308
1309
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 " +
1310
1312
indent + " return *this;\n " +
1311
1313
indent + " }\n " +
1312
1314
indent + " #endif\n " ,
You can’t perform that action at this time.
0 commit comments