Skip to content

Commit fe12572

Browse files
committed
mapi_lib: combine memcpy+assign within EXT_PULL::g_str
1 parent 390b25f commit fe12572

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/mapi/ext_buffer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ pack_result EXT_PULL::g_str(std::string *out) try
193193
auto len = strnlen(&m_cdata[m_offset], m_data_size - m_offset);
194194
if (len + 1 > m_data_size - m_offset)
195195
return pack_result::format;
196-
out->resize(len);
197-
/* Copy with, and advance over, NUL */
198-
memcpy(out->data(), &m_udata[m_offset], len + 1);
196+
out->assign(reinterpret_cast<const char *>(&m_udata[m_offset]), len);
199197
return advance(len + 1);
200198
} catch (const std::bad_alloc &) {
201199
return pack_result::alloc;

0 commit comments

Comments
 (0)