mirror of
https://github.com/holub/mame
synced 2025-04-26 10:13:37 +03:00
Fixed issue that could cause core_filename_ends_with() to return true when extension.size() > filename.size()
This commit is contained in:
parent
32230ae648
commit
210d5cb451
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user