From b351280b5bb9e4113e98cf38e49694c949b58066 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Thu, 14 Oct 2021 23:16:17 +0200 Subject: [PATCH] Always verify that position1 is not equal to string_view::npos in main.cpp --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 559791d..35f93a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,14 +50,15 @@ int main(int argc, char* argv[]) { } catch (const Yerbacon::Exception& error) { unsigned long lastSlash = 0; unsigned long position1 = fileName.find_last_of('/'); + const bool isNPOS = cmp_equal(position1, string_view::npos) if constexpr(filesystem::path::preferred_separator == '/') { - if (cmp_not_equal(position1, string_view::npos)) { + if (not isNPOS) { lastSlash = position1; } } else { unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator); if (cmp_not_equal(position2, string_view::npos)) { - lastSlash = max(position1, position2); + lastSlash = (isNPOS) ? position2 : max(position1, position2); } } resultingPair.first = fileName.substr(lastSlash + 1);