Fix crash when using Find/FindLast on empty String

This commit is contained in:
Wojtek Figat
2021-02-05 11:55:21 +01:00
parent 089f0dab3a
commit 2da9ed4556

View File

@@ -220,7 +220,7 @@ public:
/// <returns>The index of the found substring or -1 if not found.</returns>
int32 Find(const T* subStr, StringSearchCase searchCase = StringSearchCase::CaseSensitive, int32 startPosition = -1) const
{
if (subStr == nullptr)
if (subStr == nullptr || !_data)
return -1;
const T* start = _data;
if (startPosition != -1)
@@ -241,7 +241,7 @@ public:
int32 FindLast(const T* subStr, StringSearchCase searchCase = StringSearchCase::CaseSensitive, int32 startPosition = -1) const
{
const int32 subStrLen = StringUtils::Length(subStr);
if (subStrLen == 0)
if (subStrLen == 0 || !_data)
return -1;
if (startPosition == -1)
startPosition = Length();