catching null strings in Str::starts_with/ends_with

This commit is contained in:
Noel Berry 2021-05-19 11:20:08 -07:00
parent b68729850b
commit 78f6f66bff

View File

@ -262,8 +262,11 @@ Str& Str::trim()
bool Str::starts_with(const char* str, bool ignoreCase) const
{
if (str == nullptr)
return m_length == 0;
int len = (int)strlen(str);
if (len > m_length || len <= 0)
if (len > m_length)
return false;
const char* a = data();
@ -320,6 +323,9 @@ bool Str::contains(const char* str, bool ignoreCase) const
bool Str::ends_with(const char* str, bool ignoreCase) const
{
if (str == nullptr)
return m_length == 0;
int len = (int)strlen(str);
if (len > m_length || len <= 0)
return false;