Prevent undefined memcpy calls

This commit is contained in:
rexy712 2020-04-11 22:31:24 -07:00
parent f6d44c38fc
commit 8d51604f02

View File

@ -139,8 +139,10 @@ namespace rexy{
if(newsize < m_cap)
return false;
string_intermediary tmp(newsize);
memcpy(tmp.get(), m_data, m_length);
tmp[m_length] = 0;
if(m_data){
memcpy(tmp.get(), m_data, m_length);
tmp[m_length] = 0;
}
*this = std::move(tmp);
return true;
}
@ -152,7 +154,8 @@ namespace rexy{
m_data[m_length] = 0;
}else{
string_intermediary tmp(detail::max(m_length + len, m_cap*2));
memcpy(tmp.m_data, m_data, m_length);
if(m_data)
memcpy(tmp.m_data, m_data, m_length);
memcpy(tmp.m_data+m_length, data, len);
tmp.m_length = len+m_length;
tmp[m_length+len] = 0;