Clean up user/chan modes on deoper, fix memsets off-by-1, delete[] properly in destructor

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9182 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
aquanight 2008-03-23 21:36:16 +00:00
parent 8727da5903
commit fb958dd6e4

View File

@ -233,13 +233,13 @@ User::~User()
if (this->AllowedUserModes)
{
delete AllowedUserModes;
delete[] AllowedUserModes;
AllowedUserModes = NULL;
}
if (this->AllowedChanModes)
{
delete AllowedChanModes;
delete[] AllowedChanModes;
AllowedChanModes = NULL;
}
@ -704,8 +704,8 @@ void User::Oper(const std::string &opertype, const std::string &opername)
if (!AllowedUserModes)
AllowedUserModes = new bool[64];
memset(AllowedUserModes, 0, 63);
memset(AllowedChanModes, 0, 63);
memset(AllowedUserModes, 0, 64);
memset(AllowedChanModes, 0, 64);
char* Classes = strdup(iter_opertype->second);
char* myclass = strtok_r(Classes," ",&savept);
@ -727,7 +727,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
{
if (*c == '*')
{
memset(this->AllowedUserModes, (int)(true), 63);
memset(this->AllowedUserModes, (int)(true), 64);
}
else
{
@ -738,7 +738,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
{
if (*c == '*')
{
memset(this->AllowedChanModes, (int)(true), 63);
memset(this->AllowedChanModes, (int)(true), 64);
}
else
{
@ -792,6 +792,17 @@ void User::UnOper()
delete AllowedOperCommands;
AllowedOperCommands = NULL;
}
if (AllowedUserModes)
{
delete[] AllowedUserModes;
AllowedUserModes = NULL;
}
if (AllowedChanModes)
{
delete[] AllowedChanModes;
AllowedChanModes = NULL;
}
}
}