Skip to content

Commit

Permalink
BString: fix possible infinite loop in _DoReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicah committed Jun 7, 2014
1 parent 2f32fd1 commit a0b864f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kits/support/String.cpp
Expand Up @@ -2595,10 +2595,13 @@ BString::_DoReplace(const char* findThis, const char* replaceWith,
|| fromOffset < 0 || fromOffset >= Length())
return *this;

int32 findLen = strlen(findThis);
if (findLen == 0)
return *this;

typedef int32 (BString::*TFindMethod)(const char*, int32, int32) const;
TFindMethod findMethod = ignoreCase
? &BString::_IFindAfter : &BString::_FindAfter;
int32 findLen = strlen(findThis);

if (!replaceWith)
replaceWith = "";
Expand Down

0 comments on commit a0b864f

Please sign in to comment.