From 0243ae46547631c72e826ef28caae0637e7723dd Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 3 Mar 2021 13:12:29 +0100 Subject: Fix #8799: NGameAllowedSorter() is not imposing strict weak ordering relation (#8801) In other words, it should only (!) return true if A comes for B. This promise was broken for the situation where two values are identical. It would return true in these cases too. This is of course not possible: if two values are identical, neither come before the other. As such, the sorter was not imposing strict weak ordering relations. libstdc++ handled this scenario just fine, but libc++ crashes badly on this, as it allowed comparing of [begin, end] instead of [begin, end). libc++ considered this not a bug (and by specs, they are correct; just this way of crashing is of course a bit harsh): https://bugs.llvm.org/show_bug.cgi?id=47903 --- src/network/network_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network') diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 3e799221d..ae263cf00 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -333,7 +333,7 @@ protected: if (r == 0) r = a->info.use_password - b->info.use_password; /* Finally sort on the number of clients of the server in reverse order. */ - return (r != 0) ? r < 0 : !NGameClientSorter(a, b); + return (r != 0) ? r < 0 : NGameClientSorter(b, a); } /** Sort the server list */ -- cgit v1.2.3-70-g09d2