]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix User::ChangeRealHost() to change the real host properly.
authorPeter Powell <petpow@saberuk.com>
Sat, 23 Dec 2017 14:45:36 +0000 (14:45 +0000)
committerPeter Powell <petpow@saberuk.com>
Sat, 23 Dec 2017 15:35:50 +0000 (15:35 +0000)
src/users.cpp

index b3546a134c9890f6380b71e10d634a301f46e05a..41caa5c5a4b8a69cef4c8e6d97a5abc92cdc550c 100644 (file)
@@ -1018,15 +1018,27 @@ bool User::ChangeDisplayedHost(const std::string& shost)
 
 void User::ChangeRealHost(const std::string& host, bool resetdisplay)
 {
-       if (displayhost == host)
+       // If the real host is the new host and we are not resetting the
+       // display host then we have nothing to do.
+       const bool changehost = (realhost != host);
+       if (!changehost && !resetdisplay)
                return;
        
+       // If the displayhost is not set and we are not resetting it then
+       // we need to copy it to the displayhost field.
        if (displayhost.empty() && !resetdisplay)
                displayhost = realhost;
 
+       // If the displayhost is the new host or we are resetting it then
+       // we clear its contents to save memory.
        else if (displayhost == host || resetdisplay)
                displayhost.clear();
 
+       // If we are just resetting the display host then we don't need to
+       // do anything else.
+       if (!changehost)
+               return;
+
        realhost = host;
        this->InvalidateCache();
 }