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:34 +00:00
parent 90703f99ee
commit 0c609bc17e

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)