From Aurelien Albert, "I've go some problem with the method "State_Utils::replace" : if the original_phrase is empty, it leads to an infinite loop.

Here is a path to prevent this."
This commit is contained in:
Robert Osfield
2013-08-05 12:00:59 +00:00
parent 044f16b8b9
commit 41b1fcffe6

View File

@@ -1325,6 +1325,9 @@ namespace State_Utils
{
bool replace(std::string& str, const std::string& original_phrase, const std::string& new_phrase)
{
// Prevent infinite loop : if original_phrase is empty, do nothing and return false
if (original_phrase.empty()) return false;
bool replacedStr = false;
std::string::size_type pos = 0;
while((pos=str.find(original_phrase, pos))!=std::string::npos)