From dc94060e7ed73ceb4903f28ef40752405e81fe41 Mon Sep 17 00:00:00 2001 From: Cristi Mitrana Date: Mon, 9 Dec 2019 20:06:49 +0200 Subject: [PATCH] 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 `/`. --- es-core/src/utils/FileSystemUtil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index a30d0ca2d..198705361 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -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