getGenericPath: don't remove trailing '/' when path is '/'.

This prevents 'getAbsolutePath' to get into a loop with an empty path and EmulationStation to crash when the `$CWD` is `/`.
This commit is contained in:
Cristi Mitrana 2019-12-09 20:06:49 +02:00
parent 939bc817e6
commit dc94060e7e

View file

@ -237,8 +237,8 @@ namespace Utils
while((offset = path.find("//")) != std::string::npos)
path.erase(offset, 1);
// remove trailing '/'
while(path.length() && ((offset = path.find_last_of('/')) == (path.length() - 1)))
// remove trailing '/' when the path is more than a simple '/'
while(path.length() > 1 && ((offset = path.find_last_of('/')) == (path.length() - 1)))
path.erase(offset, 1);
// return generic path