From ffc8da574264a2613de4b7347002b3a1aaed3f4d Mon Sep 17 00:00:00 2001 From: Luis Scheurenbrand Date: Thu, 11 Mar 2021 00:11:31 +0100 Subject: [PATCH] don't try to sort 18446744073709551615 entries if non exist --- common/hekate.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common/hekate.cpp b/common/hekate.cpp index 32d8fd1..d103aff 100644 --- a/common/hekate.cpp +++ b/common/hekate.cpp @@ -119,14 +119,16 @@ namespace Hekate { break; } - /* Reorder ini files by ASCII ordering. */ - char temp[0x100]; - for (size_t i = 0; i < count - 1 ; i++) { - for (size_t j = i + 1; j < count; j++) { - if (std::strcmp(dir_entries[i], dir_entries[j]) > 0) { - std::strcpy(temp, dir_entries[i]); - std::strcpy(dir_entries[i], dir_entries[j]); - std::strcpy(dir_entries[j], temp); + if (count > 1) { + /* Reorder ini files by ASCII ordering. */ + char temp[0x100]; + for (size_t i = 0; i < count - 1 ; i++) { + for (size_t j = i + 1; j < count; j++) { + if (std::strcmp(dir_entries[i], dir_entries[j]) > 0) { + std::strcpy(temp, dir_entries[i]); + std::strcpy(dir_entries[i], dir_entries[j]); + std::strcpy(dir_entries[j], temp); + } } } }