diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index 6b49b9d50..cefbeb30f 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -141,7 +141,9 @@ namespace BAN bool String::operator==(const char* other) const { - return memcmp(m_data, other, m_size + 1) == 0; + if (m_size != strlen(other)) + return false; + return memcmp(m_data, other, m_size) == 0; } ErrorOr String::Resize(size_type size, char ch) diff --git a/BAN/BAN/StringView.cpp b/BAN/BAN/StringView.cpp index 02c751d93..b86d78c73 100644 --- a/BAN/BAN/StringView.cpp +++ b/BAN/BAN/StringView.cpp @@ -45,7 +45,9 @@ namespace BAN bool StringView::operator==(const char* other) const { - return memcmp(m_data, other, m_size + 1) == 0; + if (m_size != strlen(other)) + return false; + return memcmp(m_data, other, m_size) == 0; } StringView StringView::Substring(size_type index, size_type len) const