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/server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index b7e58c56b..30d204aa4 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -70,7 +70,10 @@ std::string InspIRCd::GetVersionString(bool operstring) { char versiondata[MAXBUF]; if (operstring) - snprintf(versiondata,MAXBUF,"%s %s :%s [%s,%s,%s]",VERSION,Config->ServerName.c_str(),SYSTEM,REVISION,SE->GetName().c_str(),Config->sid.c_str()); + { + std::string sename = SE->GetName(); + snprintf(versiondata,MAXBUF,"%s %s :%s [%s,%s,%s]",VERSION, Config->ServerName.c_str(), SYSTEM,REVISION, sename.c_str(), Config->sid.c_str()); + } else snprintf(versiondata,MAXBUF,"%s %s :%s",BRANCH,Config->ServerName.c_str(),Config->CustomVersion.c_str()); return versiondata; -- cgit v1.3.1-10-gc9f91