diff options
author | Marvin Kopf <marvinkopf@posteo.de> | 2017-04-01 13:57:51 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2017-04-01 13:57:51 +0200 |
commit | 974c054bc97c312f13c81bafbc6c6f6d933088bd (patch) | |
tree | 3dbac9ce144672fa304e4a8452bdcc75063298a6 /src/StringUtils.cpp | |
parent | Add Fllamber to BACKERS file. (diff) | |
download | cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar.gz cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar.bz2 cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar.lz cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar.xz cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.tar.zst cuberite-974c054bc97c312f13c81bafbc6c6f6d933088bd.zip |
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index e70c2dc50..4ff556277 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -374,11 +374,17 @@ size_t RateCompareString(const AString & s1, const AString & s2) void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith) { + // find always returns the current position for an empty needle; prevent endless loop + if (iNeedle.empty()) + { + return; + } + size_t pos1 = iHayStack.find(iNeedle); while (pos1 != AString::npos) { iHayStack.replace( pos1, iNeedle.size(), iReplaceWith); - pos1 = iHayStack.find(iNeedle, pos1); + pos1 = iHayStack.find(iNeedle, pos1 + iReplaceWith.size()); } } |