mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-04-21 12:27:27 +03:00
Avoid out-of-range lookup when FileLister::browse is passed empty string
When the path is the empty string, it is handled as the current working directory, which is consistent with how relative paths are handled.
This commit is contained in:
@@ -71,8 +71,9 @@ bool FileLister::browse(const string& path, bool clean)
|
|||||||
}
|
}
|
||||||
|
|
||||||
string slashedPath = path;
|
string slashedPath = path;
|
||||||
if (path[path.length() - 1] != '/')
|
if (!path.empty() && path[path.length() - 1] != '/') {
|
||||||
slashedPath.push_back('/');
|
slashedPath.push_back('/');
|
||||||
|
}
|
||||||
|
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
if ((dirp = opendir(slashedPath.c_str())) == NULL) {
|
if ((dirp = opendir(slashedPath.c_str())) == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user