summaryrefslogtreecommitdiff
path: root/src/modules/m_silence.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-09-30 01:10:57 +0200
committerattilamolnar <attilamolnar@hush.com>2012-09-30 03:04:07 +0200
commit02859be56d43bcece02aab350e02bc95ed1bf446 (patch)
treebbb68a91e26f4502c22047ad2b26ed8918c5fbb1 /src/modules/m_silence.cpp
parent83e90c4baa1215caf05295aec86a0a4d7bfff3f9 (diff)
Fix more undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary
See 83c7cc45daf6fb1f8c36f15297a4657e45a34e88
Diffstat (limited to 'src/modules/m_silence.cpp')
-rw-r--r--src/modules/m_silence.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 089d59931..81e4bc3d8 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -125,7 +125,8 @@ class CommandSilence : public Command
{
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
{
- user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), DecompPattern(c->second).c_str());
+ std::string decomppattern = DecompPattern(c->second);
+ user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), decomppattern.c_str());
}
}
user->WriteNumeric(272, "%s :End of Silence List",user->nick.c_str());
@@ -161,6 +162,7 @@ class CommandSilence : public Command
if (action == '-')
{
+ std::string decomppattern = DecompPattern(pattern);
// fetch their silence list
silencelist* sl = ext.get(user);
// does it contain any entries and does it exist?
@@ -173,7 +175,7 @@ class CommandSilence : public Command
if (listitem == mask && i->second == pattern)
{
sl->erase(i);
- user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
if (!sl->size())
{
ext.unset(user);
@@ -182,7 +184,7 @@ class CommandSilence : public Command
}
}
}
- user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
}
else if (action == '+')
{
@@ -198,12 +200,14 @@ class CommandSilence : public Command
user->WriteNumeric(952, "%s %s :Your silence list is full",user->nick.c_str(), user->nick.c_str());
return CMD_FAILURE;
}
+
+ std::string decomppattern = DecompPattern(pattern);
for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
{
irc::string listitem = n->first.c_str();
if (listitem == mask && n->second == pattern)
{
- user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
return CMD_FAILURE;
}
}
@@ -215,7 +219,7 @@ class CommandSilence : public Command
{
sl->push_back(silenceset(mask,pattern));
}
- user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
return CMD_SUCCESS;
}
}