From 8364e1189821fc8e8fb47a7a3d0ad7a023bfbdf3 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 21 Aug 2014 04:17:59 +0200 Subject: [PATCH] Fix extremely rare and extremely weird bug Under certain conditions, it was possible to get orderLinks() trigger a segmentation fault or a SIGBUS; even if all the Link* and Linkapp* pointers where correct, the compare_links() function would eventually end up receiving an invalid pointer. Apparently, the std::sort function *requires* that the assertion compare_links(a, b) != compare_links(b, a) is always true, which was not the case previously when a link was compared with itself. --- src/menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu.cpp b/src/menu.cpp index c57cd0b..171109b 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -797,7 +797,7 @@ static bool compare_links(Link *a, Link *b) return false; if (app2_is_opk && !app1_is_opk) return true; - return a->getTitle().compare(b->getTitle()) <= 0; + return a->getTitle().compare(b->getTitle()) < 0; } void Menu::orderLinks()