From 83c7cc45daf6fb1f8c36f15297a4657e45a34e88 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Sun, 23 Sep 2012 02:51:16 +0200 Subject: Fix undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary Thanks to @ChrisTX for pointing this out Fixes #257 reported by @helloall --- src/modules/m_alias.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/m_alias.cpp') diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index ec426fe9b..6cb336c83 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -87,7 +87,8 @@ class ModuleAlias : public Module { ConfigTag* tag = i->second; Alias a; - a.AliasedCommand = tag->getString("text").c_str(); + std::string aliastext = tag->getString("text"); + a.AliasedCommand = aliastext.c_str(); tag->readString("replace", a.ReplaceFormat, true); a.RequiredNick = tag->getString("requires"); a.ULineOnly = tag->getBool("uline"); -- cgit v1.2.3