From 41b1fcffe6b80c5d95156a9795505edaa8da8ea3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 5 Aug 2013 12:00:59 +0000 Subject: [PATCH] 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." --- src/osg/State.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index a14bee877..a09e34b0f 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -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)