[ox/std] Fix possible error that occurs with appending on boundary of small string size
This commit is contained in:
parent
ba1bf950a8
commit
c753881747
8
deps/ox/src/ox/std/string.hpp
vendored
8
deps/ox/src/ox/std/string.hpp
vendored
@ -423,9 +423,10 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
|
|||||||
const std::size_t strLen = src.len();
|
const std::size_t strLen = src.len();
|
||||||
const auto currentLen = len();
|
const auto currentLen = len();
|
||||||
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
||||||
cpy.m_buff.resize(m_buff.size() + strLen);
|
cpy.m_buff.resize(m_buff.size() + strLen + 1);
|
||||||
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
|
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
|
||||||
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen + 1);
|
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen);
|
||||||
|
cpy.m_buff[cpy.m_buff.size() - 1] = 0;
|
||||||
return cpy;
|
return cpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +437,8 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
|
|||||||
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
|
||||||
cpy.m_buff.resize(m_buff.size() + strLen);
|
cpy.m_buff.resize(m_buff.size() + strLen);
|
||||||
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
|
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
|
||||||
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen + 1);
|
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen);
|
||||||
|
cpy.m_buff[cpy.m_buff.size() - 1] = 0;
|
||||||
return cpy;
|
return cpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user