summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-23 23:31:40 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2007-10-23 23:31:40 +0000
commitc43805606f43b3b93e76ef9a250eb0ea367b980a (patch)
treee1ab10fd5e686d8cdec616b201b9ae61346e7d65 /src
parent0b98824cc5767079f0f895111253b98843e15414 (diff)
Fix a bug before I even started this.. don't let User::SetClass() decrease the reference count if we cannot find the new class to plop them into, that will nark things up nicely..
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8338 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 74c64e730..a901552fd 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1721,11 +1721,10 @@ unsigned int User::GetMaxChans()
*/
ConnectClass* User::SetClass(const std::string &explicit_name)
{
- if (this->MyClass)
- {
- ServerInstance->Log(DEBUG, "Untying user from connect class -- refcount: %u", this->MyClass->RefCount);
- this->MyClass->RefCount--;
- }
+ ConnectClass *found = NULL;
+
+ if (!IS_LOCAL(this))
+ return NULL;
if (!explicit_name.empty())
{
@@ -1733,7 +1732,7 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
{
if (explicit_name == i->GetName())
{
- this->MyClass = &(*i);
+ found = &(*i);
}
}
}
@@ -1747,22 +1746,34 @@ ConnectClass* User::SetClass(const std::string &explicit_name)
{
if (this->GetPort() == i->GetPort())
{
- this->MyClass = &(*i);
+ found = &(*i);
}
else
continue;
}
else
{
- this->MyClass = &(*i);
+ found = &(*i);
}
}
}
}
- this->MyClass->RefCount++;
- ServerInstance->Log(DEBUG, "User tied to class -- connect refcount now: %u", this->MyClass->RefCount);
- /* will only happen for remote users. */
+ /* ensure we don't fuck things up refcount wise, only remove them from a class if we find a new one :P */
+ if (found)
+ {
+ /* should always be valid, but just in case .. */
+ if (this->MyClass)
+ {
+ ServerInstance->Log(DEBUG, "Untying user from connect class -- refcount: %u", this->MyClass->RefCount);
+ this->MyClass->RefCount--;
+ }
+
+ this->MyClass = found;
+ this->MyClass->RefCount++;
+ ServerInstance->Log(DEBUG, "User tied to class -- connect refcount now: %u", this->MyClass->RefCount);
+ }
+
return this->MyClass;
}