From 1caf45cf62da1d4de288423ab188541e9a59e1e3 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 19 Apr 2025 23:56:35 +1000 Subject: [PATCH] SmallString: Fix possible non-null-termination in set_size() --- src/common/small_string.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/small_string.cpp b/src/common/small_string.cpp index b30ffb228..80feac71b 100644 --- a/src/common/small_string.cpp +++ b/src/common/small_string.cpp @@ -893,6 +893,11 @@ void SmallStringBase::set_size(u32 new_size, bool shrink_if_smaller /*= false*/) { DebugAssert(new_size <= m_buffer_size); m_length = new_size; +#if _DEBUG + std::memset(m_buffer + new_size, 0, m_buffer_size - new_size); +#else + m_buffer[new_size] = 0; +#endif if (shrink_if_smaller) shrink_to_fit(); }