diff --git a/include/inspircd.h b/include/inspircd.h index bdaa50b815..78b4b8988a 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -921,7 +921,7 @@ class CoreExport InspIRCd : public classbase /** Return a time_t as a human-readable string. */ - std::string TimeString(time_t curtime); + const std::string &TimeString(time_t curtime); /** Begin execution of the server. * NOTE: this function NEVER returns. Internally, diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp index 9cf4b7e90a..0f39dd530f 100644 --- a/src/commands/cmd_version.cpp +++ b/src/commands/cmd_version.cpp @@ -29,7 +29,8 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandVersion::Handle (const std::vector&, User *user) { - user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ServerInstance->GetVersionString().c_str()); + std::string ver = ServerInstance->GetVersionString(); + user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ver.c_str()); ServerInstance->Config->Send005(user); return CMD_SUCCESS; } diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index f5746a3953..aca19d374a 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -435,9 +435,11 @@ bool InspIRCd::SilentULine(const char* sserver) else return false; } -std::string InspIRCd::TimeString(time_t curtime) +const std::string &InspIRCd::TimeString(time_t curtime) { - return std::string(ctime(&curtime),24); + static std::string buf; + buf.assign(ctime(&curtime), 24); + return buf; } // You should only pass a single character to this. diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index 6a408d4c59..7429449d1d 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -180,7 +180,8 @@ class ModuleLDAPAuth : public Module size_t pos = user->password.find(":"); if (pos != std::string::npos) { - res = ldap_search_ext_s(conn, base.c_str(), searchscope, user->password.substr(0, pos).c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg); + std::string user_password = user->password.substr(0, pos); + res = ldap_search_ext_s(conn, base.c_str(), searchscope, user_password.c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg); if (res) { diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 8d1e5d7497..739837f7d7 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -136,8 +136,8 @@ 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(); + irc::string pattern = assign(MyConf->ReadValue("badword","text",index)); + irc::string replace = assign(MyConf->ReadValue("badword","replace",index)); censors[pattern] = replace; } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index f4e7eab8ca..3cc572fbb4 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -153,7 +153,8 @@ class ModuleKickNoRejoin : public Module { if (iter->first == user) { - user->WriteNumeric(ERR_DELAYREJOIN, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)", user->nick.c_str(), chan->name.c_str(), chan->GetModeParameter('J').c_str()); + std::string modeparam = chan->GetModeParameter('J'); + user->WriteNumeric(ERR_DELAYREJOIN, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)", user->nick.c_str(), chan->name.c_str(), modeparam.c_str()); return 1; } } diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 7d6cacb403..154983e7b5 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -119,7 +119,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 pattern = DecompPattern(c->second); + user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), pattern.c_str()); } } user->WriteNumeric(272, "%s :End of Silence List",user->nick.c_str());