summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarvin Kopf <marvinkopf@posteo.de>2017-04-01 13:57:51 +0200
committerworktycho <work.tycho@gmail.com>2017-04-01 13:57:51 +0200
commit974c054bc97c312f13c81bafbc6c6f6d933088bd (patch)
tree3dbac9ce144672fa304e4a8452bdcc75063298a6 /src
parentAdd Fllamber to BACKERS file. (diff)
downloadcuberite-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')
-rw-r--r--src/StringUtils.cpp8
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());
}
}