From 00811ee5bb454b38b6e142782109d8fa86e67602 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Wed, 26 Mar 2025 05:33:52 +0200 Subject: [PATCH] Fix endless loop in ReplaceString (#9077) --- src/libslic3r/PrintConfig.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index ae7f72a745..7446f4cfb7 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -39,7 +39,10 @@ std::set SplitStringAndRemoveDuplicateElement(const std::string &st void ReplaceString(std::string &resource_str, const std::string &old_str, const std::string &new_str) { std::string::size_type pos = 0; - while ((pos = resource_str.find(old_str)) != std::string::npos) { resource_str.replace(pos, old_str.length(), new_str); } + while ((pos = resource_str.find(old_str, pos)) != std::string::npos) { + resource_str.replace(pos, old_str.length(), new_str); + pos += new_str.length(); //advance position to continue after replacement + } } }