From c753881747cb036aadf9172b1cca0ab7af5d1948 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 19 Jan 2025 09:26:06 -0600 Subject: [PATCH] [ox/std] Fix possible error that occurs with appending on boundary of small string size --- deps/ox/src/ox/std/string.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deps/ox/src/ox/std/string.hpp b/deps/ox/src/ox/std/string.hpp index caaf105f..baf8f2d6 100644 --- a/deps/ox/src/ox/std/string.hpp +++ b/deps/ox/src/ox/std/string.hpp @@ -423,9 +423,10 @@ constexpr BasicString BasicString::operato const std::size_t strLen = src.len(); const auto currentLen = len(); BasicString 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[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; } @@ -436,7 +437,8 @@ constexpr BasicString BasicString::operato BasicString cpy(currentLen + strLen); cpy.m_buff.resize(m_buff.size() + strLen); 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; }