diff options
Diffstat (limited to 'src/lib/util/corefile.cpp')
-rw-r--r-- | src/lib/util/corefile.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp index 5c530b41f30..c06426015f7 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -1298,15 +1298,16 @@ bool core_filename_ends_with(const std::string &filename, const std::string &ext { auto namelen = filename.length(); auto extlen = extension.length(); - bool matches = true; + // first if the extension is bigger than the name, we definitely don't match + bool matches = namelen >= extlen; + // work backwards checking for a match - while (extlen > 0 && namelen > 0) + while (matches && extlen > 0 && namelen > 0) + { if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen])) - { matches = false; - break; - } + } return matches; } |