summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-23 14:45:36 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-23 15:35:50 +0000
commit6efee33e920a15fb2bd14a4c5275f678d33318cb (patch)
tree7aaeb4983459ad6fc5002a0d58c8d37fcf4df714 /src
parent3adafd95820df664006f81e2b3b7453747957ab1 (diff)
Fix User::ChangeRealHost() to change the real host properly.
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/users.cpp b/src/users.cpp
index b3546a134..41caa5c5a 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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();
}