summaryrefslogtreecommitdiff
path: root/src/utils/chatutils.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-02-05 21:21:49 +0300
committerAndrei Karas <akaras@inbox.ru>2017-02-05 21:21:49 +0300
commita922b6c0703026021126c8833cd4d42a27126e11 (patch)
treedacdbeb72f616e9779f93951ffc28cf1d5f13dee /src/utils/chatutils.cpp
parent5b4774d352787626061752e8dba6377b25b64f66 (diff)
downloadplus-a922b6c0703026021126c8833cd4d42a27126e11.tar.gz
plus-a922b6c0703026021126c8833cd4d42a27126e11.tar.bz2
plus-a922b6c0703026021126c8833cd4d42a27126e11.tar.xz
plus-a922b6c0703026021126c8833cd4d42a27126e11.zip
Fix incorrect buffer access in chatutils and in stringutils unit tests.
Diffstat (limited to 'src/utils/chatutils.cpp')
-rw-r--r--src/utils/chatutils.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
index 3ad6c8a1f..d80e8d761 100644
--- a/src/utils/chatutils.cpp
+++ b/src/utils/chatutils.cpp
@@ -146,12 +146,16 @@ void replaceVars(std::string &str)
if (*it != localPlayer->getName())
newStr.append(*it).append(",");
}
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
if (!newStr.empty())
+ {
+ if (newStr[newStr.size() - 1] == ',')
+ newStr = newStr.substr(0, newStr.size() - 1);
replaceAll(str, "<PEOPLE>", newStr);
+ }
else
+ {
replaceAll(str, "<PEOPLE>", "");
+ }
}
if (str.find("<PARTY>") != std::string::npos)
{
@@ -167,12 +171,16 @@ void replaceVars(std::string &str)
if (*it != localPlayer->getName())
newStr.append(*it).append(",");
}
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
if (!newStr.empty())
+ {
+ if (newStr[newStr.size() - 1] == ',')
+ newStr = newStr.substr(0, newStr.size() - 1);
replaceAll(str, "<PARTY>", newStr);
+ }
else
+ {
replaceAll(str, "<PARTY>", "");
+ }
}
else
{