BString: fix possible infinite loop in _DoReplace

This commit is contained in:
Jessica Hamilton 2014-06-07 22:14:21 +12:00
parent 2f32fd1dde
commit a0b864f0e4

View File

@ -2595,10 +2595,13 @@ BString::_DoReplace(const char* findThis, const char* replaceWith,
|| fromOffset < 0 || fromOffset >= Length()) || fromOffset < 0 || fromOffset >= Length())
return *this; return *this;
int32 findLen = strlen(findThis);
if (findLen == 0)
return *this;
typedef int32 (BString::*TFindMethod)(const char*, int32, int32) const; typedef int32 (BString::*TFindMethod)(const char*, int32, int32) const;
TFindMethod findMethod = ignoreCase TFindMethod findMethod = ignoreCase
? &BString::_IFindAfter : &BString::_FindAfter; ? &BString::_IFindAfter : &BString::_FindAfter;
int32 findLen = strlen(findThis);
if (!replaceWith) if (!replaceWith)
replaceWith = ""; replaceWith = "";