From: danieldg Date: Fri, 17 Apr 2009 13:55:14 +0000 (+0000) Subject: Fix memory leak on rehash: opertype used char* instead of std::string X-Git-Tag: v2.0.23~1915 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=1735fc95bba84044d43d4490bd5916d0a52eb876;p=user%2Fhenk%2Fcode%2Finspircd.git Fix memory leak on rehash: opertype used char* instead of std::string git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11309 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/include/configreader.h b/include/configreader.h index 7761ca94a..29289dcaf 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -224,7 +224,7 @@ struct MultiConfig /** A set of oper types */ -typedef std::map opertype_t; +typedef std::map opertype_t; /** Holds an oper class. */ diff --git a/src/configreader.cpp b/src/configreader.cpp index e23f5750d..0fcf88e9d 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -2205,15 +2205,6 @@ bool ValueItem::GetBool() */ bool InitTypes(ServerConfig* conf, const char*) { - if (conf->opertypes.size()) - { - for (opertype_t::iterator n = conf->opertypes.begin(); n != conf->opertypes.end(); n++) - { - if (n->second) - delete[] n->second; - } - } - conf->opertypes.clear(); return true; } @@ -2250,7 +2241,7 @@ bool DoType(ServerConfig* conf, const char*, char**, ValueList &values, int*) const char* TypeName = values[0].GetString(); const char* Classes = values[1].GetString(); - conf->opertypes[TypeName] = strnewdup(Classes); + conf->opertypes[TypeName] = std::string(Classes); return true; } diff --git a/src/users.cpp b/src/users.cpp index c84bc00d9..15e1ab72b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -776,7 +776,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. std::string myclass, mycmd, mypriv; - irc::spacesepstream Classes(iter_opertype->second); + irc::spacesepstream Classes(iter_opertype->second.c_str()); while (Classes.GetToken(myclass)) { operclass_t::iterator iter_operclass = ServerInstance->Config->operclass.find(myclass.c_str());