Adding a check for reverse overflow when extensions is longer than filename

This commit is contained in:
Nathan Woods 2016-07-11 10:46:36 -04:00
parent 0e4cb93bc5
commit 32230ae648

View File

@ -1300,8 +1300,8 @@ bool core_filename_ends_with(const std::string &filename, const std::string &ext
auto extlen = extension.length();
bool matches = true;
/* work backwards checking for a match */
while (extlen > 0)
// work backwards checking for a match
while (extlen > 0 && namelen > 0)
if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen]))
{
matches = false;