diff --git a/Source/Engine/Core/Types/String.h b/Source/Engine/Core/Types/String.h
index 542d2f9b3..9b053f8b5 100644
--- a/Source/Engine/Core/Types/String.h
+++ b/Source/Engine/Core/Types/String.h
@@ -48,6 +48,7 @@ public:
/// The character
FORCE_INLINE T& operator[](int32 index)
{
+ ASSERT(index >= 0 && index < _length);
return _data[index];
}
@@ -58,6 +59,7 @@ public:
/// The character
FORCE_INLINE const T& operator[](int32 index) const
{
+ ASSERT(index >= 0 && index < _length);
return _data[index];
}
@@ -441,15 +443,9 @@ public:
/// Number of replacements made (in other words number of occurences of searchText).
int32 Replace(const T* searchText, int32 searchTextLength, const T* replacementText, int32 replacementTextLength, StringSearchCase searchCase = StringSearchCase::CaseSensitive)
{
- if (!HasChars())
+ if (!HasChars() || searchTextLength == 0)
return 0;
- if (searchTextLength == 0)
- {
- ASSERT(false); // Empty search text never makes sense, and is always sign of a bug in calling code.
- return 0;
- }
-
int32 replacedCount = 0;
if (searchTextLength == replacementTextLength)