From 02859be56d43bcece02aab350e02bc95ed1bf446 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 30 Sep 2012 01:10:57 +0200 Subject: Fix more undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary See 83c7cc45daf6fb1f8c36f15297a4657e45a34e88 --- src/modules/m_censor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/modules/m_censor.cpp') diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 5e832cc8b..bbf061f7e 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -128,9 +128,10 @@ class ModuleCensor : public Module for (int index = 0; index < MyConf.Enumerate("badword"); index++) { - irc::string pattern = (MyConf.ReadValue("badword","text",index)).c_str(); - irc::string replace = (MyConf.ReadValue("badword","replace",index)).c_str(); - censors[pattern] = replace; + std::string str = MyConf.ReadValue("badword","text",index); + irc::string pattern(str.c_str()); + str = MyConf.ReadValue("badword","replace",index); + censors[pattern] = irc::string(str.c_str()); } } -- cgit v1.3.1-10-gc9f91