From de48b69760c8cd360a169202d5b874cb5b52ea6b Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 30 Apr 2022 18:31:53 +0200 Subject: [PATCH] Prevented a potential endless loop in StringUtil::replace() --- es-core/src/utils/StringUtil.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/es-core/src/utils/StringUtil.cpp b/es-core/src/utils/StringUtil.cpp index cb3d1cc3b..9440f0f35 100644 --- a/es-core/src/utils/StringUtil.cpp +++ b/es-core/src/utils/StringUtil.cpp @@ -606,6 +606,10 @@ namespace Utils replaced.append(result.substr(lastPos)); result = replaced; + + // Prevent endless loops. + if (to.find(from) != std::string::npos) + break; } return result; }