From 6efee33e920a15fb2bd14a4c5275f678d33318cb Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sat, 23 Dec 2017 14:45:36 +0000 Subject: Fix User::ChangeRealHost() to change the real host properly. --- src/users.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/users.cpp') 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(); } -- cgit v1.3.1-10-gc9f91